Ich bin nicht vertraut mit der Verwendung von ManualResetEvent?In Bezug auf die Verwendung von ManualResetEvent Verwendung C#?
ist es Thread verwandt. was es tut und wann es verwendet wird?
hier habe ich einen Code, in dem Manual verwendet wird, aber ich verstehe einfach nicht, was sie tut?
hier ist der Code
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();
}
// ...
}
, was die Bedeutung von _complete.WaitOne(); & _complete.Set(); ?
ist
kann mir jemand gibt kleinen Beispielcode in die Manual Klasse Nutzungs da sein.
der Suche nach guten diskutieren und Nutzung von Manual? Dank