Invoke and BeginInvoke reprint address: http://www.cnblogs.com/worldreason/archive/2008/06/09/1216127.htmlIn the use of Invoke or BeginInvoke no exception to the use of the delegate delegate, as to the nature of the Commission, please refer to my other essay: views on. NET events.First, why does the control class provide the invoke and BeginInvoke mechanisms?The
Control. Invoke method (delegate): executes the specified delegate on the thread that owns the basic window handle of this control.
Control. begininvoke method (delegate): executes the specified delegate asynchronously on the thread where the basic handle of the control is created.
(1) control invoke and begininvokeBased on the following knowledge:(1) The invoke
The delegate delegate is used without exception in the use of Invoke or BeginInvoke.First, why does the control class provide the invoke and BeginInvoke mechanisms?The main reason for this problem is already known to the dotnet programmers, I am here to pay a bit of ink to record their own log, in order to remind myself later.1. Windows program Message mechanismThe Windows GUI program is message-based, and
Reference: Invoke and BeginInvoke understandingWindows GUI programs based on message loop mechanismpublic static void Main (string[] args){Form f = new form ();Application.Run (f);}. NET Form program encapsulates the while loop, which is initiated by the Application.Run method. If you manipulate a control on a form from another thread, it will compete with the main thread, causing unpredictable results or even deadlocks. So Windows GUI programming has
? There are many solutions! For example, users who are familiar with multi-thread programming will soon think that we adopt some low-level synchronization methods, and the worker thread will save the state to a synchronization object so that the UI thread can polling) this object can be fed back to the user. However, this is quite troublesome. In fact, you don't need to do this,The control class (and its derived class) object has a very special invoke
Invoke and begininvoke (this is the link for source code analysis in my blog)
In the use of invoke or begininvoke, the delegate is used without exception. For the nature of the Delegate, please refer to another article: Views on. NET events.I. Why does the control class provide the invoke and begininvoke mechanisms?The main reason for this problem is already well
Parallel use of Parallel. Invoke,
The Parallel class is in the namespace of System. Threading. Tasks.
There are several methods below. Here we will talk about the usage of Invoke.
Below we define several methods to facilitate testing
First customize Response to prevent the result changes caused by occupying in parallel
HttpResponse MyResponse = System. Web. HttpContext. Current. Response;
public vo
case, the control.invokerequired attribute and the Invoke method are used. ------------------------------------------------------------------------gets a value that indicates whether the caller must call the Invoke method when making a method call to the control, because the call is in a thread other than the one on which the control is created. If the control's Handle is created on a different thread than
InUseWithout exceptionUseAs for the nature of delegation, please refer to another article: my views on. NET events.
I. Why does the control class provide the invoke and begininvoke mechanisms?
The main reason for this problem is already well known by dotnetprogrammers. I have recorded my own logs again here so that I can remind myself later.
1. Windows program message mechanism
The Windows GUI program is based on the message mechanism, and a main thre
ZT: http://www.x2blog.cn/jinhong618? Tid = 22389
In the design, in order to separate the interface from the logic, my approach is to use the event. The interface only needs to respond to the event to process the display of the interface. Events may be triggered by different threads in logical processing. The response methods of these events will cause an exception when modifying the control content on the interface.
The control. invokerequired attribute and the
1. Problem Reproduction
In the previous practice of reducing. Net memory usage, I shared with you the use of P/invoke technology in. Net to call the unmanaged code written in C ++.Code. Although the performance and memory usage are good, in the next few weeks, some colleagues' machines often encounter exceptions and cause applications.ProgramCrash, especially on some machines with better configurations. Therefore, the log record is improved, and the
We will discuss how to use Win32 in C # and other libraries to manage functions without. net.
C # The user often asks two questions: "Why is there another problem?WriteCodeTo use Windows built-in functions? Why didn't I complete the task for me in the framework ?" When the Framework Team built their. net section, they evaluated. NetProgramWorkers can use Win32 to complete the work. The result shows that the Win32 API set is very large. They do not have enough resources for allWin32 APIs writ
In the design, in order to separate the interface from the logic, my approach is to use the event. The interface only needs to respond to the event to process the display of the interface. Events may be triggered by different threads in logical processing. The response methods of these events will cause an exception when modifying the control content on the interface.The control. invokerequired attribute and the invoke method are used.Msdn says:Gets a
JS invoke executable (EXE) file*************************************************************************************************************** ************************************************************************************************************************ *********1.0 use Java to invoke Windows system EXE files, such as Notepad,calc:public class demo{public static void Main (String args[]) {Runtime
I. Why does the control class provide the invoke and begininvoke mechanisms?
The main reason for this problem is already well known by dotnetprogrammers. I have recorded my own logs again here so that I can remind myself later.1. Windows program message mechanism
The Windows GUI program is based on the message mechanism, and a main thread maintains a message pump. This message pump keeps Windows programs running.Message loop in Windows GUI Program
A
Original posts: http://www.cnblogs.com/Z-King/archive/2011/11/03/2234337.htmlhas been the use of invoke and BeginInvoke and the concept of confusion, the two days to read some information, the use of these two and the principle of a new understanding and understanding.First of all, there are two scenarios for invoke and BeginInvoke use:1. Invoke, BeginInvoke in c
From:http://www.th7.cn/program/net/201306/140033.shtml
Controls in Windows forms are bound to a specific thread and do not have thread safety. Therefore, if you invoke a control's method from another thread, you must use an Invoke method of the control to marshal the call to the appropriate thread. This property can be used to determine whether the Invoke met
Dispatch_propertyget
The member is retrieved as a property or data member.This is the most critical address of this article, if the value you return is a COM object, will the caller increase AddRef? No, so you need to add the count yourself, or the program will soon crash
Provides access to properties and methods exposed by an object. The dispatch function Dispinvoke provides a standard implementation of Invoke.Syntaxc++HRESULT
The problem arises:
My WinForm program has a worker thread that updates the main window, but the document prompts me not to call this form in multiple threads (why?). , and the fact that my program often collapses when I call. How do I call a method in form from multiple threads?
Answer:
Each WinForm class (including the control class) derived from the control class relies on the underlying Windows message and a message pump loop (Messages pump loop). The message loop must have a correspondin
Close a form today and report this error. "You cannot call invoke or begininvoke on the control before creating a window handle. ", You don't have to think about it. It must have been the place that was not released.Now that you have encountered this problem, let alone the problem itself. Let's talk about other things.The most common control of winform is the datagridview control. Many data operations are displayed by using the datagridview. Therefore
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.