Example:
Using system;using system.collections.generic;using system.linq;using system.text;using System.Threading.Tasks;using System.Threading;namespace ConsoleApplication6{ class Program { private Delegate int asyctaskdelegate (INT I, INT J); static void main (String[] args) { AsycTaskDelegate std = asyctask; iasyncresult sr = std. BeginInvoke (1, 1000, null, null); //set the wait time to 2 seconds, if the task is completed within 3 seconds, perform the following method if (Sr. Asyncwaithandle.waitone (+)) { console.writeline (" Received signal "); } else { Console.WriteLine ("Signal loss"); } console.writeline (Std. EndInvoke (SR)); console.readkey (); } private Static int asyctask (int i, int j) { console.writeline ("Please wait ..."); thread.sleep (j); return ++i; } }}
650) this.width=650; "title=" Sogou 20150210235050.png "src=" http://s3.51cto.com/wyfs02/M00/59/A2/wKioL1TaKd6SP_ N5aaalbzah6ag594.jpg "alt=" Wkiol1takd6sp_n5aaalbzah6ag594.jpg "/>
This article is from the "program Ape's Home--hunter" blog, please be sure to keep this source http://962410314.blog.51cto.com/7563109/1613513
Thread----WaitHandle abstract base class (wait handle)