TitleSearch titleSearch = new TitleSearch();
ImageSearch imageSearch = new ImageSearch();
SemanticSearch semanticSearch = new SemanticSearch();
new Task(() => resultTitleSearchXmlData=titleSearch.Operation(keyword)),
//시맨틱 검색 결과
new Task(() => resultSemanticSearchXmlData=semanticSearch.General(catgory,keyword)),
//이미지 검색결과
new Task(() => resultImageSearchXmlData=imageSearch.Operation(keyword))
};
{
threads[i].Start();
}
Task.WaitAll(threads);
또는
델리게이트를 이용한 비동기 멀티스레딩
//비동기 엔진 호출을 위한 메소드 선언
public delegate XmlDocument ImageDele(string keyword);
public delegate XmlDocument TitleDele(string keyword);
SemanticDele semanticDele = new SemanticDele(semanticSearch.General);
ImageDele imageDele = new ImageDele(imageSearch.Operation);
TitleDele titleDele = new TitleDele(titleSearch.Operation);
IAsyncResult semanticSearchResult = semanticDele.BeginInvoke(catgory, keyword, null, null);
IAsyncResult titleSearchResult = titleDele.BeginInvoke(keyword, null, null);
IAsyncResult imageSearchResult = imageDele.BeginInvoke(keyword, null, null);
//Do some other work on priamry thread..
resultTitleSearchXmlData = titleDele.EndInvoke(titleSearchResult);
resultImageSearchXmlData = imageDele.EndInvoke(imageSearchResult);
resultSemanticSearchXmlData = semanticDele.EndInvoke(semanticSearchResult);
'Programming > C#' 카테고리의 다른 글
| 비동기 호출하기(델리게이트, 스레드 이용) (0) | 2011/10/20 |
|---|---|
| https GET 결과 가져오기 (0) | 2011/10/06 |
| C# DES 암호화(Encrypt), 복호화(Decrypt) (0) | 2010/08/18 |
| 인덱서 (0) | 2010/08/06 |
| 나열형(enum)과 구조체(struct) 선언. (0) | 2010/07/20 |
sqljdbc_2.0.1803.100_kor.exe