-
[C#] Thread, Thread 인자 전달, BeginInvoke, Invoke 복붙용Microsoft .NET/C# 2021. 3. 17. 11:05
Thread
Thread th = new Thread(new ThreadStart(functionSample)); th.Start(); private void functionSample() { }
Thread 인자 전달
// Type - 1 Thread th = new Thread(() => functionSample("전자기린", 29)); th.Start(); private void functionSample(string name, int age) { } // Type - 2 Thread th = new Thread(new ParameterizedThreadStart(functionSample)); th.Start("전자기린"); private void functionSample(object _name) { string name = _name as string; }
BeginInvoke - 비동기
Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { })); //xamarin.forms Device.BeginInvokeOnMainThread(() => { });
Invoke - 동기
Application.Current.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { }));
'Microsoft .NET > C#' 카테고리의 다른 글
[C#] string 타입 형식지정 (0) 2021.10.15 [C#] ColorDialog (색상 선택 컨트롤, 다이얼로그) (0) 2020.07.14 [C#] OpenFileDialog, SaveFileDialog, CommonOpenFileDialog, ColorDialog (0) 2020.03.10 [C#] 폴더 압축 / 다중 파일 압축 / 압축 해제 (0) 2020.01.06 [C#] 16진수(hex) 문자열<-> Byte[] 변환 (0) 2020.01.03