本文整理汇总了C#中System.Threading.ManualResetEvent.Set方法的典型用法代码示例。如果您正苦于以下问题:C# System.Threading.ManualResetEvent.Set方法的具体用法?C# System.Threading.ManualResetEvent.Set怎么用?C# System.Threading.ManualResetEvent.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Threading.ManualResetEvent
的用法示例。
在下文中一共展示了System.Threading.ManualResetEvent.Set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Scan
public override Task<Result> Scan (MobileBarcodeScanningOptions options)
{
return Task.Factory.StartNew(() => {
try
{
var scanResultResetEvent = new System.Threading.ManualResetEvent(false);
Result result = null;
this.appController.InvokeOnMainThread(() => {
// Free memory first and release resources
if (viewController != null)
{
viewController.Dispose();
viewController = null;
}
viewController = new ZxingCameraViewController(options, this);
viewController.BarCodeEvent += (BarCodeEventArgs e) => {
viewController.DismissViewController();
result = e.BarcodeResult;
scanResultResetEvent.Set();
};
viewController.Canceled += (sender, e) => {
viewController.DismissViewController();
scanResultResetEvent.Set();
};
appController.PresentViewController(viewController, true, () => { });
});
scanResultResetEvent.WaitOne();
return result;
}
catch (Exception ex)
{
return null;
}
});
}
示例2: RunUpdate
public void RunUpdate()
{
var u = Updater.Instance;
var waitHandler = new System.Threading.ManualResetEvent(false);
u.NoUpdatesFound += (s, e) => waitHandler.Set();
u.Error += (s, e) => waitHandler.Set();
u.ExternalUpdateStarted += (s, e) => waitHandler.Set();
u.UpdateCancelled += (s, e) => waitHandler.Set();
Updater.CheckUpdateSimple();
waitHandler.WaitOne();
}
示例3: 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;
}));
}
示例4: 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;
}));
}
示例5: 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();
}
示例6: 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);
}
示例7: Main
static void Main()
{
System.Threading.ManualResetEvent close = new System.Threading.ManualResetEvent(false);
SystemEvents.SessionEnding += (object sender, SessionEndingEventArgs e) =>
close.Set();
BaseClass();
close.WaitOne();
}
示例8: 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 ();
}
示例9: Scan
public override Task<Result> Scan(MobileBarcodeScanningOptions options)
{
var task = Task.Factory.StartNew(() => {
var waitScanResetEvent = new System.Threading.ManualResetEvent(false);
var scanIntent = new Intent(lifecycleListener.Context, typeof(ZxingActivity));
scanIntent.AddFlags(ActivityFlags.NewTask);
ZxingActivity.UseCustomOverlayView = this.UseCustomOverlay;
ZxingActivity.CustomOverlayView = this.CustomOverlay;
ZxingActivity.ScanningOptions = options;
ZxingActivity.ScanContinuously = false;
ZxingActivity.TopText = TopText;
ZxingActivity.BottomText = BottomText;
ZxingActivity.Orientation = Orientation;
Result scanResult = null;
ZxingActivity.CanceledHandler = () =>
{
waitScanResetEvent.Set();
};
ZxingActivity.ScanCompletedHandler = (Result result) =>
{
scanResult = result;
waitScanResetEvent.Set();
};
lifecycleListener.Context.StartActivity(scanIntent);
waitScanResetEvent.WaitOne();
return scanResult;
});
return task;
}
示例10: RunAsync
public async Task RunAsync ( Action act )
{
await Task.Run ( ( ) =>
{
System.Threading.ManualResetEvent evt = new System.Threading.ManualResetEvent ( false );
m_dispatcher.BeginInvoke ( ( ) =>
{
act ( );
evt.Set ( );
} );
evt.WaitOne ( );
} );
}
示例11: Scan
public override Task<Result> Scan(MobileBarcodeScanningOptions options)
{
Console.WriteLine("ZXING MOBILE: Scan");
var waitScanResetEvent = new System.Threading.ManualResetEvent(false);
var scanIntent = new Intent(this.Context, typeof(ZxingActivity));
ZxingActivity.UseCustomView = this.UseCustomOverlay;
ZxingActivity.CustomOverlayView = this.CustomOverlay;
ZxingActivity.ScanningOptions = options;
ZxingActivity.TopText = TopText;
ZxingActivity.BottomText = BottomText;
var task = Task.Factory.StartNew(() => {
Result scanResult = null;
ZxingActivity.OnCanceled += () =>
{
waitScanResetEvent.Set();
};
ZxingActivity.OnScanCompleted += (Result result) =>
{
scanResult = result;
waitScanResetEvent.Set();
};
this.Context.RunOnUiThread(() => this.Context.StartActivity(scanIntent));
waitScanResetEvent.WaitOne();
return scanResult;
});
return task;
}
示例12: Main
static void Main(string[] args)
{
//Load initial settings
Logger.Logger.Get("Runner").Message("App started");
//Logger.Logger.Get().Message("App started");
WorkerProcess.GetInstance().Process();
System.Threading.ManualResetEvent _quitEvent = new System.Threading.ManualResetEvent(false);
Console.CancelKeyPress += (sender, eArgs) => {
_quitEvent.Set(); eArgs.Cancel = true;
};
_quitEvent.WaitOne();
}
示例13: AskForConnectionAsync
internal async Task<Connection> AskForConnectionAsync()
{
using (var closedEvent = new System.Threading.ManualResetEvent(false))
{
var dialog = new ConnectionDialog();
dialog.Closed += (sender, e) =>
{
closedEvent.Set();
};
dialog.Show();
await Task.Run(new Action(() => closedEvent.WaitOne()));
if (dialog.Ok ?? false)
return dialog.Connection;
else
return null;
}
}
示例14: GetIsCertificateTrusted
public bool GetIsCertificateTrusted (string uri, string certificateFingerprint)
{
bool value;
if (!TrustedCertificates.TryGetValue (certificateFingerprint, out value)) {
using (var handle = new System.Threading.ManualResetEvent (false)) {
Gtk.Application.Invoke (delegate {
value = MessageService.AskQuestion (
"Untrusted HTTP certificate detected",
string.Format ("Do you want to temporarily trust this certificate in order to" +
" connect to the server at {0}?", uri),
AlertButton.Yes, AlertButton.No) == AlertButton.Yes;
TrustedCertificates [certificateFingerprint] = value;
handle.Set ();
});
handle.WaitOne ();
}
}
return value;
}
示例15: ManagerFileWatcher
public void ManagerFileWatcher()
{
// PluginManager should be able to reload plugins that exist on file when the
// plugin's file is changed.
System.Threading.ManualResetEvent reset = new System.Threading.ManualResetEvent(false);
IronPlugins.PluginManager mgr = new IronPlugins.PluginManager();
mgr.PluginReloaded += new IronPlugins.PluginManager.PluginReloadedEventHandler(
delegate(object sender, IronPlugins.PluginReloadEventArgs args)
{
reset.Set();
}
);
IronPlugins.Plugin.FilePlugin filePlugin = new IronPlugins.Plugin.FilePlugin("file_manager_test.py");
mgr.AddPlugin(filePlugin);
// Write a new attribute to the file. This imitates someone changing a plugin file.
using (System.IO.TextWriter writer = new System.IO.StreamWriter("file_manager_test.py"))
{
writer.Write("new_attribute = 82");
}
reset.WaitOne(); // Wait for the plugin to be reloaded
Assert.IsTrue(filePlugin.Invoke("new_attribute") == 82); // Check if the new attribute exists
mgr.Dispose();
}