3. Implementation/C#
How to invoke with more than one parameter
SSKK
2011. 8. 16. 22:33
C#에 익숙하지 않아서인지 이런 구문이 자꾸 헷갈리네요. MFC 에 비해서 워낙 쉽다는 느낌을 많이 받아서인지 그다지 C# 고유의 문법에 깊이 빠져들지 못합니다. 아래 예제는 Invoke 메소드를 이용하여 여러 파라미터를 넘기는 방법에 대해서 소개하고 있습니다. 이전까지는 매번 같은 파라미터를 가지는 delegate 를 선언했었는데, 역시 stupid 한 방법이었습니다. ㅋㅋ
출처: http://stackoverflow.com/questions/729430/c-how-to-invoke-with-more-than-one-parameter
public void DoSomething(string foo, int bar) { if (this.InvokeRequired) { this.Invoke((MethodInvoker)delegate { DoSomething(foo,bar); }); return; } // do something with foo and bar this.Text = foo; Console.WriteLine(bar); }
출처: http://stackoverflow.com/questions/729430/c-how-to-invoke-with-more-than-one-parameter