I have the following scenario:
My application should import multiple datasets from another application, and time is critical.
Because of this, it generates one thread for each import.
So let's say I have import 1 througth 10 where import 4 and 5 can only start after import 1, 6 and 7 after import 2 and 8, 9 and 10 after import 3
- Import 1
- Import 2
- Import 3
- Import 8
- Import 9
- Import 10
stackoverflow waithandles, , waithandles.
/ , , .set().
, , - , .
, ?
UPDATE:
, , :
dateSince = Convert.ToDateTime(txtBoxDateSince.Text);
dateTo = Convert.ToDateTime(txtBoxDateTo.Text);
//Loop all the days on the time interval
while (DateTime.Compare(dateSince, dateTo) <= 0)
{
foreach (ListItem father in checkBoxListFather.Items)
{
if (father.Selected == true)
{
processClass process = new processClass();
var wh = new ManualResetEvent(false);
WaitCallback fatherMethod = new WaitCallback(process.importProcess);
processClass.importParameters param = new processClass.importParameters(wh, father.Value, null, dateSince);
ThreadPool.QueueUserWorkItem(fundMethod, param);
foreach (ListItem child in checkBoxListChild.Items)
{
if (child.Selected == true)
{
processClass.importParameters parameters = new processClass.importParameters(null, child.Value, null, dateSince);
WaitOrTimerCallback childMethod = new WaitOrTimerCallback(process.anotherImportProcess);
RegisteredWaitHandle rwh = ThreadPool.RegisterWaitForSingleObject(wh, childMethod, parameters, Timeout.Infinite, true);
}
}
}
}
dateSince = dtSince.AddDays(1);
}// while (DateTime.Compare(from, to) < 0)
, - .
, .
.