Home > Articles > Programming > C#

  • Print
  • + Share This
Like this article? We recommend

A Simple Multithreaded User-System Dialog

Our problem boils down to the case of initiating a device upload process. Figure 2 illustrates a sneak preview of the basic solution. Remember, we’re just dealing with concepts—a real network management solution would be altogether more complex.

In Figure 2, the DOS console shows the actual upload process. One thread is created, called "Worker," which executes the UploadFirmware() method of the class UploadContent. The work of transferring the firmware data is handled notionally by the lines that follow: "Block 1 of 6", "Block 2 of 6", etc.

Figure 2

Figure 2 The multithreaded upload procedure.

Where’s the multithreaded content in Figure 2? Notice the dialog box entitled "Now available," which appears at the same time as the upload occurs. In other words, we could extend the "Now available" dialog box to include other application menu options. Then we could select the latter menu options at the same time as our upload is occurring. In other words, we have multithreaded execution. When the upload is finished, we’ll see the line "Block 6 of 6" in the DOS console (as illustrated in Figure 2).

The key point is that the upload can occur in parallel while we’re interacting with another part of the application (via the dialog box in Figure 2). Now let’s look at the code in Figure 2.

  • + Share This
  • 🔖 Save To Your Account