Current location - Quotes Website - Personality signature - What other steps must c# perform to make asynchronous calls to the methods of the class?
What other steps must c# perform to make asynchronous calls to the methods of the class?
Traditional asynchronism (no thread pool) has several necessary steps.

Step 1: Define the method, which will be called asynchronously.

Step 2: Define the delegate, and the signature of the delegate is consistent with the method defined in step 1.

Step 3: Instantiate the delegate defined in step 2 and refer to the method defined in step 1.

Step 4: Prepare the parameters for issuing asynchronous calls as required; If no parameters are needed, use null instead of parameters in step 5.

Step 5: Call the delegate's BeginInvoke method for asynchronous call.

If you use a thread pool to make asynchronous calls, the process is relatively simple.

Step 1: Define the method, which will be called asynchronously. Note: This method must conform to the WaitCallback delegate signature.

Step 2: use the static method of ThreadPool. QueueUserWorkItem makes asynchronous calls.