Pas*_*cal 8 c# delegates asynchronous
我上下搜索谷歌但我找不到关于该主题的任何适当信息.
我想做的是:
我怎么能用C#3.5做到这一点?
更新:
查看:
private void OnTextChanged(...)
{
if (SearchFormatEvent != null)
{
ICollection<object> collection = SearchFormatEvent("MySearchString");
// Do stuff on the returned collection
}
}
Run Code Online (Sandbox Code Playgroud)
SearchProvider:
// This is the delegate invoked for the async search taking the searchstring typed by the user
public delegate ICollection<object> SearchInputTextStrategy<T>(string param);
public class SearchProvider : ISearchProvider
{
private ITextView _view;
private SearchInputTextStrategy<object> searchInputDelegate;
public SearchProvider(ITextView view)
{
_view = view;
_view.SearchFormatEvent += new ConstructSearchFormatDelegate(CostructSearchFormat);
}
private string SearchFormat(string param)
{
// compute string
return string.Empty; //...
}
public ICollection<object> CostructSearchFormat(string param)
{
var searchfilter = SearchFormat(param);
IAsyncResult pendingOperation = searchInputDelegate.BeginInvoke("searchfilter",null,null);
// How can I cancel the Async delegate ?
ICollection<object> result = searchInputDelegate.EndInvoke(pendingOperation);
return result;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1859 次 |
| 最近记录: |