Suppose you have a Windows Forms application in which you want to see the intermediate progress and status of a time-consuming process in the GUI of the Main Form. This time-consuming process is running in a separate DLL. As the process progresses, the DLL sends current status/progress to the calling application (the Windows Forms application).

In the GUI of the Calling application, the progress and current status text of the process is displayed in a Progress Bar as shown below:

Let us see how we can do this in a very simple way:

Create a Main Application (Windows Forms application) as above with a "Start Process" button that starts the process in the DLL. Add a "StatusStrip" control too in the form. In the StatusStrip, add a ProgressBar (builtin) and StatusLable controls (builtin)

Create a DLL (Class Library project) with a class named "MyClass". Add the reference of this DLL into your Main Application.

Now create a public delegate to raise the Status event to show the intermediate processing status on the GUI in the Main Form as:

the progress variable is used for storing the current percentage progress of the process.

A Statustext variable is used for storing the current status message related to the process.

In the "MyClass" class, add a method TimeConsumingProcess() that simulates a process taking a lot of time. TimeConsumingProcess() is built up with smaller several tasks such as Task-1, task-2 etc. Assume each task requires a significant amount of time (to simulate the time consumption, I used the Thread.Sleep() method)Now we want to send a current status to the calling application. In order to do this, we call MyClassStatusEvent() after the ending of each task.

e.g. MyClassStatusEvent(10, "Task-1 is started. Task-1 is in process...");

Now add a reference to your DLL into your Main Application project. Then create an object of the "MyClass" and subscribe to its event as: