I have a method which loads data from 2 regions. Currently its processes region1 and then processes region 2. So its single thread. I would need to do them so its simultaneous. Here is the curent code. Please advice what do I need to do.
enter code here
public override object RProcess()
{
string queueName = Config.AppSettings["MQSIInboundQueueName"];
string Region1 = Config.AppSettings["Region1"];
string Region2 = Config.AppSettings["Region2"];
string returnMessage = string.Empty;
if (Region1.Trim().Length > 0)
{
returnMessage = ProcessMessage(string.Format(queueName, Region1));
Logger.Log(returnMessage);
}
if (Region2.Trim().Length > 0)
{
returnMessage = ProcessMessage(string.Format(queueName, Region2));
Logger.Log(returnMessage);
}
return null;
}
—
In addition to @Drew Marsh answer here if you are using older version of .net, you can invoke every operation in new thread, using
Threadclass orThreadPool.QueueUserWorkItemAnyway if you are updating
Region1orRegion2form any other place in the application, then you should consider using synchronization mechanism to access them here such aslock..