Make wait service not timeout without yelling, and making the timeout longer
This commit is contained in:
parent
67a30e491f
commit
ba1884aacb
|
|
@ -8,7 +8,7 @@ namespace RazorWebSite
|
||||||
{
|
{
|
||||||
public class WaitService
|
public class WaitService
|
||||||
{
|
{
|
||||||
private static readonly TimeSpan _waitTime = TimeSpan.FromSeconds(10);
|
private static readonly TimeSpan _waitTime = TimeSpan.FromSeconds(60);
|
||||||
private readonly ManualResetEventSlim _serverResetEvent = new ManualResetEventSlim();
|
private readonly ManualResetEventSlim _serverResetEvent = new ManualResetEventSlim();
|
||||||
private readonly ManualResetEventSlim _clientResetEvent = new ManualResetEventSlim();
|
private readonly ManualResetEventSlim _clientResetEvent = new ManualResetEventSlim();
|
||||||
|
|
||||||
|
|
@ -20,14 +20,24 @@ namespace RazorWebSite
|
||||||
public void WaitForClient()
|
public void WaitForClient()
|
||||||
{
|
{
|
||||||
_clientResetEvent.Set();
|
_clientResetEvent.Set();
|
||||||
_serverResetEvent.Wait(_waitTime);
|
|
||||||
|
if (!_serverResetEvent.Wait(_waitTime))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Timeout exceeded");
|
||||||
|
}
|
||||||
|
|
||||||
_serverResetEvent.Reset();
|
_serverResetEvent.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WaitForServer()
|
public void WaitForServer()
|
||||||
{
|
{
|
||||||
_serverResetEvent.Set();
|
_serverResetEvent.Set();
|
||||||
_clientResetEvent.Wait(_waitTime);
|
|
||||||
|
if (!_clientResetEvent.Wait(_waitTime))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Timeout exceeded");
|
||||||
|
}
|
||||||
|
|
||||||
_clientResetEvent.Reset();
|
_clientResetEvent.Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue