我不熟悉ManualResetEvent的用法吗?关于使用ManualResetEvent用法c#?
它是否与线程相关。它做什么以及何时使用?
这里我得到了一个代码,其中使用了ManualResetEvent,但我只是不明白它的作用?
这里是代码
public class Doc : SomeInterfaceFromTheDll
{
private readonly IVersion version; // An interface from the DLL.
private readonly ManualResetEvent _complete = new ManualResetEvent(false);
private bool downloadSuccessful;
// ...
public bool Download()
{
this.version.DownloadFile(this);
// Wait for the event to be signalled...
_complete.WaitOne();
return this.downloadSuccessful;
}
public void Completed(short reason)
{
Trace.WriteLine(string.Format("Notify.Completed({0})", reason));
this.downloadSuccessful = reason == 0;
// Signal that the download is complete
_complete.Set();
}
// ...
}
是什么_complete.WaitOne(); & _complete.Set(); ?
意思谁能给我小的样本代码,其中的ManualResetEvent类的使用将在那里。
寻找良好的ManualResetEvent的讨论和用法?谢谢