using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading;
|
using System.Threading.Tasks;
|
|
namespace XImaging.Automation.Service.Interface
|
{
|
public class ISimulator
|
{
|
protected bool _block = false;
|
|
public bool BlockTime(int milliseconds)
|
{
|
if (_block)
|
return false;
|
|
_block = true;
|
Task.Run(async () =>
|
{
|
await Task.Delay(TimeSpan.FromMilliseconds(milliseconds));
|
_block = false;
|
});
|
return true;
|
}
|
|
public void WaitForBlock()
|
{
|
Task waitTask = new Task(() =>
|
{
|
while (_block)
|
{
|
Thread.Sleep(500);
|
}
|
});
|
waitTask.Start();
|
waitTask.Wait();
|
}
|
}
|
}
|