Click here to Skip to main content
15,909,437 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I try to use in my project:

AJAX-style Asynchronous Progress Dialog for WinForms[^]

I don't know how to use this in my project,

for example:

In a button event click i use:

C#
winProgresIncarcare.AsyncProcessDelegate method = delegate
            {
                string NumeClientCautat = txtCautaDupaNume.Text;
                this.sClienti.DataSource = SetariAmanet.TotiClienti(NumeClientCautat);
            };
            RunAsyncOperation(method);


the progress circle appear on my form but trow an exception

C#
Cross-thread operation not valid: Control 'dVizualizareClienti' accessed from a thread other than the thread it was created on.


any suggestions how to transform my code in the same thread?
Posted

You should better ask the author of this article. Load the page with the article, locate the section "Comments and Discussions", click "Add a Comment or Question" and ask your question. The author will get a notification and a chance to reply.

—SA
 
Share this answer
 
And here some information for you on how to resolve the cross-threading issues with the UI thread:

You cannot call anything related to UI from non-UI thread. Instead, you need to use the method Invoke or BeginInvoke of System.Windows.Threading.Dispatcher (for both Forms or WPF) or System.Windows.Forms.Control (Forms only).

You will find detailed explanation of how it works and code samples in my past answers:
Control.Invoke() vs. Control.BeginInvoke()[^],
Problem with Treeview Scanner And MD5[^].

See also more references on threading:
How to get a keydown event to operate on a different thread in vb.net[^],
Control events not firing after enable disable + multithreading[^].

I don't know if the author of the article did not properly take care of that, or if it is your fault, but this is one fundamental issue of UI development every developer should know very well.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900