Amother thread question
-
My app was never designed to support threading - The GUI has a VB6 front end but I have rewritten it in VB.NET with a C# backend - don't ask :wtf: Some of the operations in the C# back end can take a long time are thus good candidates for running on a worker thread - these operations communicate back to the GUI using events - status information, adding rows to a datagrid, progress bar etc. As I am new to threads in .NET can I still use the events from the function running on the worker thread but just change the event sinks so they use BeginInvoke to update the GUI controls? The class which contains the long running operations has some database code in it - can I call that code from the long running operation on the new thread just as I would if it wasn't running on the thread? I don't believe I have any synchronisation issues as the database is always read only - the only reason I want the long running operation to run on a separate thread is so the GUI remains responsive, I dont actually intend to let the user do anything with the GUI other than maybe cancel the long running operation. TIA
-
My app was never designed to support threading - The GUI has a VB6 front end but I have rewritten it in VB.NET with a C# backend - don't ask :wtf: Some of the operations in the C# back end can take a long time are thus good candidates for running on a worker thread - these operations communicate back to the GUI using events - status information, adding rows to a datagrid, progress bar etc. As I am new to threads in .NET can I still use the events from the function running on the worker thread but just change the event sinks so they use BeginInvoke to update the GUI controls? The class which contains the long running operations has some database code in it - can I call that code from the long running operation on the new thread just as I would if it wasn't running on the thread? I don't believe I have any synchronisation issues as the database is always read only - the only reason I want the long running operation to run on a separate thread is so the GUI remains responsive, I dont actually intend to let the user do anything with the GUI other than maybe cancel the long running operation. TIA
There's a very good basic article here[^] that will probably cover most of the bases for you. It's a time saver if you don't want to reinvent the wheel with respect to UI <-> worker thread interaction. Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’