c# - TargetParameterCountException with Invoke() -


I am trying to update a control, but a cross threading exception error (note: cross-threading exception error Only occurs when debugging with VS, when I just run .exe, works fine). That's why I've gotten to the eye, and the invention method has reached. Now I am getting this error.

I am trying to use the extension method:

  public static zero invoke & lt; T & gt; (This TC, Action & lt; T & gt; Action) where T: Control {if (c.InvokeRequired) c.TopLevelControl.Invoke (action); Other verb (c); }  

Use the code below to update a progress bar.

  pb.TextLabel.Invoke (c => c.Text = "copy" + path. GetFileName (this.mp2File));  

But I am getting the following error:

The system Reflection.TargetParameterCountException was unrestricted
HResult = -2147352562 Message = Parameter Count Mismatch System.Windows.Forms StackTrace: System.Windows.Forms.Control.MarshaledInvoke on System.Windows.Forms.Control.Invoke (delegate method (control caller, delegate method, object [arg], boolean synchronous), object [] args) AV_Processor.Extensions.Invoke [T] (T C, Action`1 action) (AV_ProcessorkFormProcessorkProcessTable on AV_Processor.FormProcessor.buttonProcess_Click on AV_Processor.FormProcessor.Copy (Int32 ubiquitous) Int32 PState) (at object sender, EventArgs e) System.Windows.Forms.Button.OnMouseUp (MouseEventArgs mevent) on SystemkWindowskFormskControlkWmMouseUp (message & amp; m, MouseButtons button, Int32 System.Windows.Forms .Control). System WndProc (Message in Windows & amp; amp; M) m) in System.Windows.Forms.NativeWindow.DebuggableCallback in .Forms.ButtonBase.WndProc (Message & amp; System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW (IntPtr hWnd, Int32 message, IntPtr wParam, IntPtr lParam); System.Windows.Forms.Button.WindProc (Me & amp; nbsp; on Message) (MSG & amp; msg) on ​​the system. Application Companent Manager. System. Windows .form. UNICEF Native Memoirs. Component Manager. Apush Message Lapse (Interrupt vs. idid id, 32, Inter 32 POLopadata) System. Windows .form. Application Thread Conteks Krn message Inner Loop (Int32 AV_InterfacekFormInterface IWin32Window owner) due ApplicationContext context) System.Windows.Forms.Form.ShowDialog (at SystemkWindowskFormskApplicationkThreadContextkRunMessageLoop (Int32 reason ApplicationContext context). ButtonSubmit_Click (Object Sender, EventArgs E) in C: \ User \ Texture \ Document \ Visual Studio 2010 \ Projects \ madeup \ madeup \ V-interface \ FormInterface.cs: System.Window S.Forms.Button on line 756. OnMouseUp (MouseEventArgs mevent) system. WindowskFormskControlkWmMouseUp (Message & amp; System.Windows.Forms.Control.WindProc on Sistmkvindokformkbitonbejkvedprok (Message & M) system Prkvindokformkbtn. Andropi (Message and amp on M, Mausbutns button, Intros click); m) System.Windows.Forms.NativeWindow.DebuggableCallback (IntPtr (hWnd, Int32 message, IntPtr wParam, IntPtr lParam) MSG in SystemkWindowskFormskUnsafeNativeMethodskDispatchMessageW & Amp; Message) on System.Windows.Forms.Application System Manager.windo.form.scci.wondo.form. Compensant manager, FUSH Message Loop (Interactive Entertainment ID, Int 32 Reason, Int 32 POLopadata) on System.indo.form. Application Thread Contex .Ron Message Loop Inner (Intern 32 Reason, APC Contact Practice) on the system. Application c. In: \ User \ donkeykong \ document \ Visual Studio 2010 \ Projects \ blahblah source: AV_Interface.FormInterface.Main () Thread Contekstent Mensej loop (Int32 reason, ApplicationContext context) controlled \ Bababa \ sosdfg \ FormInterface.cs: line System.AppDomain._nExecuteAssembly 362 (Sort assembly assembly on Microsoft, String [] Arges). Visual Studio System.Threading.ExecutionContext.RunInternal (ExecutionContext Execution Context on SystemProcess.HostProc.RunUsersAssembly), on the system. Callback, Object State, Boolean Protected SyncTXT) On the system threading. Execution Contex Run (Execution Contaxx Execution Context, Context Callback Callback, Object State, Boolean Circuit Sync CTX) on system. threading. Execution Contex Run (execute Kantaks Akspleshment Conteks, Contaktclalt callback, object state) System.Threading.ThreadHelper.ThreadStart () InnerException:

I have set to compile all the CPU, but Cross Thread exception error occurs when I call it VS Run in debugger How do I run the above code in debugger?


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -