I am thinking of using an LED like indicator light to display (green to red) when something is completed.
My current code goes something like this:
bool saveSingleSampleDone = false;
private void btnSingleSampleData_Click(object sender, EventArgs e)
{
LEDindicator.Image = global::OnlineData.Properties.Resources.green_indicator;
LEDindicator.Refresh();
while (!saveSingleSampleDone);
if (saveSingleSampleDone)
{
LEDindicator.Image = global::OnlineData.Properties.Resources.red_indicator;
LEDindicator.Refresh();
}
}
where saveSingleSampleDone
flag is triggered from a thread running.
The issue is that the code will hang due to the while (!saveSingleSampleDone);
statement, and that this way of writing is not neat anyway.
I was thinking of starting a timer in a thread to track the start and the end of the event, but my question is that is there a more elegant way of achieving the indication without using a timer?