When I click the button, the cycle starts to read the database and send each row of the query to another server. When get response - the cycle continues.
Code is implemented as follows
private ManualResetEvent _mre = new ManualResetEvent(true);
and
Thread startUpload = new Thread(() =>
{
//read database
foreach (DataRow dr in dt.Rows)
{
//send request
_mre.WaitOne();
}
});
startUpload.Start();
The problem is that when requests are sent may not be the answer. In my case this is normal. But if not, the answer comes, then the cycle stops. I need to do inside the loop timer, which in the case of stopping the cycle due to lack of response will continue to cycle in 30 seconds.
The timer will have to do
_mre.Set();