I am very new to threading in .NET and have limited exposure to threading in Java. In short, I have a form that has a System.Windows.Forms.Timer
object. The Timer ticks every 1000ms. The event handler merely checks a bool class variable (i.e. processingResponseFiles) to determine whether or not a current operation to process request files is in process. If not in progress, it should process any request files. Otherwise, it should do nothing.
The ProcessRequestFiles
method looks at the request and then runs a BackgroundWorker
to perform the work. The issue that I am struggling with is that the value of processingResponseFiles is always false even though I am assigning it to true in the first statement of the ProcessingRequestFiles method. Can someone please tell me why the value of processingResponseFiles is always false even though I am setting it in the ProcessRequestFile()
method?
I need to protect this method so that it does not get executed more than once.
private void timerRequestTimer_Tick(object sender, EventArgs e)
{
if (!processingResponseFiles)
{
ProcessRequestFile();
}
private void ProcessRequestFile()
{
processingResponseFiles = true;
// Process Request Files
// If request type is Synchronize Customers
// Run thread that synchronizes customers
// If request type is Synchronize Items
// Run thread that synchronizes items
processingResponseFiles = false;
}