Good afternoon fellow forumites

I've been coding in VB on and off for the last ten years, but I've only now identified a requirement for multi-threading in my Windows Forms project.

I'm in the process of building a new application which makes it possible for the end-user to run a variety of different file imports. The application contains a single form which itself contains a combo box, a button, a multi-line text box and two progress bars.

The combo box enables the user to select the import that s/he wants to run, and the button enables him/her to then go ahead and run that import. The multi-line text-box is used to provide the user with feedback on what is actually happening at that particular point, whilst the two progress bars provide a graphical representation of how far the process has gone - the first progress bar tracks lets the user see how many files have been/have still to be processed while the second progress bar tracks the progress within the current file.

Each of the import processes is coded into a separate module, thus making it easier for me to isolate and troubleshoot any issues (as well as making the code much easier to read). The status text-box and progress bars are updated using a further separate Functions module, with the various functions being called at the appropriate points.

Whilst testing some of the larger modules, I started receiving a series of Managed Debugging Assistant exceptions being called. From memory, the majority of these were DisconnectedContext breaks - when I did some reading on these, everything I read seemed to suggest that the breaks were being caused by the fact that everything is being done on a single thread and therefore the UI isn't being refreshed often enough.

I've managed to work out how to have a particular module called within a thread, but as soon as I do that, I lose the functionality that provides either textual or graphical feedback to the end-user. Therefore, I need to understand how I code the calls to the functions that update the status box and progress bars so that the user is getting the feedback that s/he would want. At this point I should reiterate that I have never worked with multiple threads before, so the terminology is all very bewildering at the moment.

If anyone can give me any pointers on this, I'll be more than grateful.

TIA


Ian Henderson