I have two Windows forms. One shows the details of a single record (Job Form) and the other shows a grid containing summary information of several records (Job Log). When I update data in the job form I can invoke a method which refreshes the data in the job log. It works fine but the job log takes a while to update and meanwhile the job form is locked out.
I would like the refresh of the job log to be asynchronous and I have tried using things like[C#]
It doesn't work and I think there is a problem that I am calling from a UI thread and invoking a UI thread.
An exception is thrown when I try to reset the grid binding source - System.InvalidOperationException "A multithreading issue is detected. The DevExpress.Data.CurrencyDataController.DisableThreadingProblemsDetection option allows you to disable the exception, but it does not resolve the underlying issue."
Is it possible to run a method from one form to update a grid in another form asynchronously? If you could help me with the steps required to get this working, maybe with a C# sample, it would be much appreciated.
WinForms controls are not thread-safe. That is why it is incorrect to access them from a background thread explicitly or implicitly. Please refer to the Can I avoid the ArgumentOutOfRangeException when updating the Grid's data KB article for more information in this regard.
If you need to update data asynchronously, detach your datasource from GridControl and start the asynchronous Task. Once your operation is completed, assign new data to GridControl in the UI thread.
Let me know if this information is helpful.