출처 : http://www.codeproject.com/KB/cs/Threadsafe_formupdating.aspx
public static class ExtensionMethod {
public static TResult SafeInvoke<T, TResult>(this T isi, Func<T, TResult> call) where T : ISynchronizeInvoke {
if(isi.InvokeRequired) {
IAsyncResult result = isi.BeginInvoke(call, new object[] { isi });
object endResult = isi.EndInvoke(result);
return (TResult)endResult;
} else
return call(isi);
}
public static void SafeInvoke<T>(this T isi, Action<T> call) where T : ISynchronizeInvoke {
if(isi.InvokeRequired)
isi.BeginInvoke(call, new object[] { isi });
else
call(isi);
}
}
'IT > Dot Net' 카테고리의 다른 글
asp.net development server port issue (0) | 2012.02.08 |
---|---|
[펌]Visual Studio 2010 OutOfMemoryException (0) | 2012.01.12 |
C# 으로 안드로이드 또는 아이폰 어플 개발 (0) | 2011.04.06 |
[FarPoint Spread]데이터와 헤더라벨을 고려한 컬럼너비 자동조정 구현 (0) | 2010.11.12 |
[펌]Clickonce 인증서 만료시 해결책 - 기존 인증서 만료기간 수정 (0) | 2010.11.05 |