1. Delegate invoke and begininvoke
1.1. Delegate. Invoke
Delegate. Invoke is used to execute a delegate on the current thread. We know that the delegate is a reference to a function or method, and delegate. Invoke is the call
Use methods or functions.
1.2. Delegate. begininvoke
Delegate. begininvoke is used to asynchronously execute a delegate and execute it in a separate thread, so it does not block the current thread. Before calling
After delegate. bigininvoke, you must call endinvoke at a certain time to avoid resource leakage. Because the delegate method is in a separate thread
Attributes of the new UI thread or call any methods that may update the UI. For example, if you want to update a progress bar and fill in a list or other similar work,
A different mechanism must be used: Control. invoke or control. begininvoke.
2. Control invoke and begininvoke
2.1. Control. Invoke
It is used to execute delegation in the UI thread where the control is located. If you have a delegate for updating the UI, you can call control. Invoke from other threads to execute more
New operation.
2.2. Control. begininvoke
Control. begininvoke does the same thing. The difference is that it is asynchronous. That is to say, Control. Invoke waits for the UI thread to complete the update operation, while
Control. begininvoke returns immediately without blocking the current thread.