本文整理汇总了C#中System.Threading.ManualResetEvent类的典型用法代码示例。如果您正苦于以下问题:C# System.Threading.ManualResetEvent类的具体用法?C# System.Threading.ManualResetEvent怎么用?C# System.Threading.ManualResetEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Threading.ManualResetEvent类属于命名空间,在下文中一共展示了System.Threading.ManualResetEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DbThreadsGator
public DbThreadsGator(bool gateIsOpen)
{
if (gateIsOpen)
gate = new System.Threading.ManualResetEvent(true);
else
gate = new System.Threading.ManualResetEvent(false);
}
示例2: Scan
public override Task<Result> Scan(MobileBarcodeScanningOptions options)
{
var rootFrame = RootFrame ?? Window.Current.Content as Frame ?? ((FrameworkElement) Window.Current.Content).GetFirstChildOfType<Frame>();
var dispatcher = Dispatcher ?? Window.Current.Dispatcher;
return Task.Factory.StartNew(new Func<Result>(() =>
{
var scanResultResetEvent = new System.Threading.ManualResetEvent(false);
Result result = null;
ScanPage.ScanningOptions = options;
ScanPage.ResultFoundAction = (r) =>
{
result = r;
scanResultResetEvent.Set();
};
ScanPage.UseCustomOverlay = this.UseCustomOverlay;
ScanPage.CustomOverlay = this.CustomOverlay;
ScanPage.TopText = TopText;
ScanPage.BottomText = BottomText;
dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
rootFrame.Navigate(typeof(ScanPage));
});
scanResultResetEvent.WaitOne();
return result;
}));
}
示例3: Scan
public override Task<Result> Scan(MobileBarcodeScanningOptions options)
{
return Task.Factory.StartNew(new Func<Result>(() =>
{
var scanResultResetEvent = new System.Threading.ManualResetEvent(false);
Result result = null;
//Navigate: /ZxingSharp.WindowsPhone;component/Scan.xaml
ScanPage.ScanningOptions = options;
ScanPage.ResultFoundAction = (r) =>
{
result = r;
scanResultResetEvent.Set();
};
ScanPage.UseCustomOverlay = this.UseCustomOverlay;
ScanPage.CustomOverlay = this.CustomOverlay;
ScanPage.TopText = TopText;
ScanPage.BottomText = BottomText;
Dispatcher.BeginInvoke(() =>
{
((Microsoft.Phone.Controls.PhoneApplicationFrame)Application.Current.RootVisual).Navigate(
new Uri("/ZXingNetMobile;component/ScanPage.xaml", UriKind.Relative));
});
scanResultResetEvent.WaitOne();
return result;
}));
}
示例4: ADTFile
public ADTFile(WDTFile wdt, string fileName, uint indexX, uint indexY, bool initial = false)
{
bool unkFlag = (wdt.Flags & 0x84) != 0;
if (unkFlag)
throw new Exception();
IndexX = indexX;
IndexY = indexY;
FileName = fileName;
mLoadEvent = new System.Threading.ManualResetEvent(false);
if (initial == false)
{
Game.GameManager.ThreadManager.LaunchThread(
() =>
{
try
{
AsyncLoadProc();
}
catch (Exception)
{
}
}
);
}
else
AsyncLoadProc();
ADTManager.AddADT(this);
}
示例5: ConnectionManagerAddsNewServicesFromServiceDiscovery
public void ConnectionManagerAddsNewServicesFromServiceDiscovery()
{
var manualResetEvent = new System.Threading.ManualResetEvent(false);
var serviceUri1 = new ServiceUri() { Address = "1" };
var serviceUri2 = new ServiceUri() { Address = "2" };
Dictionary<ServiceUri, PerformanceStatistics> services
= new Dictionary<ServiceUri, PerformanceStatistics>()
{
{serviceUri1, new PerformanceStatistics()},
{serviceUri2, new PerformanceStatistics()}
};
var serviceDiscoveryMock = new Mock<IServiceDiscovery>(MockBehavior.Strict);
serviceDiscoveryMock.Setup(sd => sd.GetPerformanceStatistics()).Returns(() => services).Callback(() => manualResetEvent.Set());
var manager = new ConnectionManager(remoteService: null, listener: null,
serviceDiscovery: serviceDiscoveryMock.Object,
serviceDiscoveryPeriod: new TimeSpan(days: 0, hours: 0, minutes: 0, seconds: 0, milliseconds: 10));
manualResetEvent.WaitOne();
manager.RemoteServices.Count().ShouldBe(2);
services.Add(new ServiceUri(), new PerformanceStatistics());
manualResetEvent.Reset();
manualResetEvent.WaitOne();
manager.RemoteServices.Count().ShouldBe(3);
}
示例6: RunItems
private void RunItems(List<WaitItem> waitItems)
{
try
{
System.Threading.ManualResetEvent[] mre = new System.Threading.ManualResetEvent[waitItems.Count];
for (int i = 0; i < waitItems.Count; i++)
{
mre[i] = waitItems[i].MRE;
}
foreach (WaitItem item in waitItems)
{
item.MRE.Reset();
System.Threading.ThreadPool.QueueUserWorkItem(ThreadExecute, item);
}
System.Threading.WaitHandle.WaitAll(mre);
foreach (WaitItem item in waitItems)
{
if (item.Error != null)
throw item.Error;
}
}
finally
{
foreach (WaitItem item in waitItems)
{
Push(item);
}
waitItems.Clear();
}
}
示例7: SendMessage_Test
public void SendMessage_Test()
{
RequestMessage message = new RequestMessage()
{
Device = "test",
Level = MessageLevel.High,
Message = "test",
Source = "unitest",
Title = "test"
};
ResponseMessage resmessage = CatsAgent.SendMessage(message);
var t1 = resmessage.Message;
var t2 = resmessage.Result;
Assert.IsTrue(t1.Length > 0);
Assert.AreEqual(t2, MessageSendingResult.Succeed);
System.Threading.ManualResetEvent hand = new System.Threading.ManualResetEvent(false);
CatsAgent.SendMessageAsync(message, new
Action<ResponseMessage>((ar) => { hand.Set(); }));
hand.WaitOne();
}
示例8: ExecuteAndWaitForSSHCommand
private static void ExecuteAndWaitForSSHCommand(string IPAddress,string command)
{
var handle = new System.Threading.ManualResetEvent(false);
var helper = new SshCommandHelper(IPAddress, handle);
helper.WriteSSHCommand(command, true);
handle.WaitOne();
}
示例9: AgentThreadInfo
public AgentThreadInfo(System.Threading.Thread thread) {
if (object.ReferenceEquals(thread, null)) { throw new ArgumentNullException("thread"); }
this.Thread = thread;
this.MainReset = new System.Threading.ManualResetEvent(false);
this.AgentReset = new System.Threading.ManualResetEvent(false);
}
示例10: NetzService
public NetzService(string[] args)
{
this.args = args;
resetEvent = new System.Threading.ManualResetEvent(false);
ServiceName = ProjectInstaller.SERVICENAME;
Init();
}
示例11: Main
static void Main()
{
System.Threading.ManualResetEvent close = new System.Threading.ManualResetEvent(false);
SystemEvents.SessionEnding += (object sender, SessionEndingEventArgs e) =>
close.Set();
BaseClass();
close.WaitOne();
}
示例12: Control
public Control(string ServerAddress, int Port)
{
log = new Logger(AppInfo.Title + Port);
m_sServerAddress = ServerAddress;
m_iPort = Port;
m_TCPClient = new System.Net.Sockets.TcpClient();
m_EventChannelConnectionComplete = new System.Threading.ManualResetEvent(false);
m_sLastError = "";
m_EventReceivedFile = new System.Threading.AutoResetEvent(false);
}
示例13: PeriodicOutput
public PeriodicOutput(ConsoleOutput messageSink, TimeSpan updateFrequency)
{
m_output = messageSink;
m_readyEvent = new System.Threading.ManualResetEvent(false);
m_finishEvent = new System.Threading.ManualResetEvent(false);
m_updateFrequency = updateFrequency;
m_thread = new System.Threading.Thread(this.ThreadMain);
m_thread.IsBackground = true;
m_thread.Name = "Periodic console writer";
m_thread.Start();
}
示例14: Parse
static void Parse()
{
var e = new System.Threading.ManualResetEvent(false);
Console.WriteLine ("Parsing...");
GlobalParseCache.BeginAddOrUpdatePaths (new[]{ srcDir }, false, (ea) => {
Console.WriteLine ("Finished parsing. {0} files. {1} ms.", ea.FileAmount, ea.ParseDuration);
e.Set();
});
e.WaitOne ();
}
示例15: CommandItem
internal bool m_UpdateRequired { get; set; } //true if this command updates a polled status variable, and an update is needed ASAP
/// <summary>
///
/// </summary>
/// <param name="command">actual serial command to be sent, not including ending '#' or the native checksum</param>
/// <param name="timeout">timeout value for this command in msec, -1 if no timeout wanted</param>
/// <param name="wantResult">does the caller want the result returned by Gemini?</param>
/// <param name="bRaw">command is a raw string to be passed to the device unmodified</param>
internal CommandItem(string command, int timeout, bool wantResult, bool bRaw)
{
m_Command = command;
m_ThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId;
m_Timeout = timeout;
// create a wait handle if result is desired
if (wantResult)
m_WaitForResultHandle = new System.Threading.ManualResetEvent(false);
m_Result = null;
m_Raw = bRaw;
}