本文整理汇总了C#中System.Threading.AutoResetEvent类的典型用法代码示例。如果您正苦于以下问题:C# System.Threading.AutoResetEvent类的具体用法?C# System.Threading.AutoResetEvent怎么用?C# System.Threading.AutoResetEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Threading.AutoResetEvent类属于命名空间,在下文中一共展示了System.Threading.AutoResetEvent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Should_be_able_to_configure_EasyNetQ_to_allow_message_with_a_blank_type_field
public void Should_be_able_to_configure_EasyNetQ_to_allow_message_with_a_blank_type_field()
{
var are = new System.Threading.AutoResetEvent(false);
var validation = new NullMessageValidator();
var bus = RabbitHutch.CreateBus("host=localhost", r =>
r.Register<IMessageValidationStrategy>(x => validation));
bus.Subscribe<MyMessage>("null_validation_test", message =>
{
Console.Out.WriteLine("Got message: {0}", message.Text);
are.Set();
});
// now use the basic client API to publish some JSON to the message type exchange ...
var factory = new RabbitMQ.Client.ConnectionFactory
{
HostName = "localhost"
};
using (var connection = factory.CreateConnection())
using (var channel = connection.CreateModel())
{
const string exchange = "EasyNetQ_Tests_MyMessage:EasyNetQ_Tests";
const string routingKey = "#";
const string bodyString = "{ Text: \"Hello from Mr Raw :)\" }";
var body = System.Text.Encoding.UTF8.GetBytes(bodyString);
var properties = channel.CreateBasicProperties();
channel.BasicPublish(exchange, routingKey, properties, body);
}
are.WaitOne(1000);
}
开发者ID:siniypin,项目名称:EasyNetQ,代码行数:31,代码来源:DefaultMessageValidationStrategyIntegrationTests.cs
示例2: Run
public static void Run(string[] args)
{
if (args.Length == 0)
{
Command.Application application = new Command.Application();
IDisposable telnet = Parser.Listen(application, "telnet://:23");
IDisposable tcp = Parser.Listen(application, "tcp://:20");
IDisposable console = Parser.Listen(application, "console:///");
}
else
{
Application application = new Application();
Settings.Module settings = new Settings.Module()
{
//Header = "<link href=\"resources/settings.css\" rel=\"stylesheet\" type=\"text/css\"/>\n <link href=\"resources/settings.css\" rel=\"stylesheet\" type=\"text/css\"/>",
};
settings.Load("loader", new Loader(settings));
settings.Load("old.object", new Object());
settings.Load("application", new Command.Application());
application.Load(settings);
application.Start();
System.Threading.AutoResetEvent wait = new System.Threading.AutoResetEvent(false);
application.OnClosed += () => wait.Set();
wait.WaitOne();
//application.Execute();
}
}
开发者ID:imintsystems,项目名称:Kean,代码行数:27,代码来源:Program.cs
示例3: Main
static void Main(string[] args)
{
// args:
// 0: jid, name
// 1: passwd
// 2: mcu jid
// 3: cmd
// 4: cmd_options
if (args.Length == 5)
{
string xmpp_domain = Environment.GetEnvironmentVariable("xmpp_domain");
if (xmpp_domain == null)
xmpp_domain = "app.zonekey.com.cn";
cs_zkrobot.client.NormalUser user = cs_zkrobot.client.UserFactory.makeNormal();
if (!user.login(args[0] + "@" + xmpp_domain, args[1]))
{
System.Console.WriteLine("login err: " + args[0] + "@" + xmpp_domain);
}
else
{
System.Console.WriteLine("req: to:" + args[2] + ", cmd=" + args[3] + ", options=" + args[4]);
System.Threading.AutoResetEvent comp_evt = new System.Threading.AutoResetEvent(false);
user.async_request(args[2] + "@" + xmpp_domain, args[3], args[4], cb_response, comp_evt);
comp_evt.WaitOne();
user.logout();
}
}
}
开发者ID:FihlaTV,项目名称:conference,代码行数:30,代码来源:Program.cs
示例4: ServerLoopTimer
public ServerLoopTimer(float period)
{
_timer = new Timer(period);
_timer.Elapsed += () => { Set(); };
_are = new AutoResetEvent(true);
_timer.Enabled = true;
}
开发者ID:SSX1,项目名称:Space-Station-X1,代码行数:7,代码来源:ServerLoopTimer.cs
示例5: DeviceLocator_Notifications_DoesNotRaiseDeviceAvailableIfDisposed
public void DeviceLocator_Notifications_DoesNotRaiseDeviceAvailableIfDisposed()
{
var server = new MockCommsServer();
var deviceLocator = new MockDeviceLocator(server);
DiscoveredSsdpDevice device = null;
bool newlyDiscovered = false;
var receivedNotification = false;
using (var eventSignal = new System.Threading.AutoResetEvent(false))
{
deviceLocator.DeviceAvailable += (sender, args) =>
{
device = args.DiscoveredDevice;
newlyDiscovered = args.IsNewlyDiscovered;
receivedNotification = true;
};
deviceLocator.StartListeningForNotifications();
server.MockReceiveBroadcast(GetMockAliveNotification());
server.Dispose();
eventSignal.WaitOne(1000);
}
Assert.IsFalse(receivedNotification);
}
开发者ID:noex,项目名称:RSSDP,代码行数:25,代码来源:DeviceLocatorTests.cs
示例6: Test
public void Test()
{
System.Threading.AutoResetEvent evt = new System.Threading.AutoResetEvent(false);
Packets.LicensePlatePacket p = null;
int count = 0;
Manager mnger = new Manager(new PacketSplitter());
var parser = new Parsers.LicensePlateParser();
parser.Handler += licensePlate =>
{
System.Diagnostics.Debug.WriteLine(licensePlate.LicensePlate.LicenseNumber);
p = licensePlate;
++count;
if (count > 1000)
{
evt.Set();
}
};
mnger.Parsers.Add(parser);
mnger.Start();
evt.WaitOne(10000);
mnger.Stop();
Assert.IsNotNull(p);
}
开发者ID:vanan08,项目名称:damany,代码行数:27,代码来源:ManagerTest.cs
示例7: PubSubTest
public void PubSubTest()
{
UdpBus bus = (UdpBus)Reflector.GetField(this.pool, "bus");
object received = null;
System.Threading.AutoResetEvent evt = new System.Threading.AutoResetEvent(false);
this.pool.Start();
HostConfiguration hostSpec = new HostConfiguration(0){ CameraID = 2, Name = "mike", };
bus.Publish(Topics.HostReply, hostSpec, 3000);
System.Threading.Thread.Sleep(6000);
var host = this.pool[hostSpec.StationID];
Assert.IsNotNull(host);
Assert.AreEqual("mike", host.Config.Name);
hostSpec.Name = "jack";
bus.Publish(Topics.HostReply, hostSpec, 3000);
System.Threading.Thread.Sleep(6000);
host = this.pool[hostSpec.StationID];
Assert.AreEqual("jack", host.Config.Name);
}
开发者ID:dalinhuang,项目名称:appcollection,代码行数:31,代码来源:HostsPoolTest.cs
示例8: flushGraphics
/// </summary>
/// <param name="rect"></param>
internal void flushGraphics(Rectangle rect)
{
using (System.Threading.AutoResetEvent are = new System.Threading.AutoResetEvent(false))
{
SilverlightImplementation.dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
IList<AsyncOp> tmp = renderingOperations;
renderingOperations = pendingRenderingOperations;
pendingRenderingOperations = tmp;
if (rect == null)
{
_screen.Invalidate();
}
else
{
_graphics.clip = rect;
_graphics.destination.setClip(rect);
_screen.Invalidate();
}
_graphics.destination.setAlpha(255);
_graphics.destination.setColor(0);
are.Set();
}).AsTask().GetAwaiter().GetResult();
are.WaitOne();
}
}
开发者ID:sannysanoff,项目名称:CodenameOne,代码行数:29,代码来源:WindowsAsyncView.cs
示例9: CapsQueueRunning
public bool CapsQueueRunning()
{
if (Client.Network.CurrentSim.Caps.IsEventQueueRunning)
return true;
bool Success = false;
// make sure caps event queue is running
System.Threading.AutoResetEvent waitforCAPS = new System.Threading.AutoResetEvent(false);
EventHandler<EventQueueRunningEventArgs> capsRunning = delegate(object sender, EventQueueRunningEventArgs e)
{
waitforCAPS.Set();
};
Client.Network.EventQueueRunning += capsRunning;
if (waitforCAPS.WaitOne(10000, false))
{
Success = true;
}
else
{
Success = false;
Assert.Fail("Timeout waiting for event Queue to startup");
}
Client.Network.EventQueueRunning -= capsRunning;
return Success;
}
开发者ID:Virtual-Universe,项目名称:Virtual-LibOMV,代码行数:27,代码来源:NetworkTests.cs
示例10: Restart
/// <summary>
/// Restart plex, wait for the specified delay between stop and start
/// </summary>
/// <param name="msDelay">The amount of time in ms to wait before starting after stop</param>
internal void Restart(int delay)
{
Stop();
State = PlexState.Pending;
System.Threading.AutoResetEvent autoEvent = new System.Threading.AutoResetEvent(false);
System.Threading.Timer t = new System.Threading.Timer((x) => { Start(); autoEvent.Set(); }, null, delay, System.Threading.Timeout.Infinite);
autoEvent.WaitOne();
t.Dispose();
}
开发者ID:howlerwolf1313,项目名称:PmsService,代码行数:13,代码来源:PmsMonitor.cs
示例11: OpenPythonConsole
public static PythonConsoleHost OpenPythonConsole(System.Windows.Forms.Form mainForm)
{
// ipy -D -X:TabCompletion -X:ColorfulConsole
if (m_pythonConsoleHost == null)
{
m_pythonConsoleHost = new PythonConsoleHost();
//System.Threading.ManualResetEvent eve = new System.Threading.ManualResetEvent(false);
dispatcher = mainForm;
System.Threading.AutoResetEvent are = new System.Threading.AutoResetEvent(false);
System.Threading.Thread _debugThread = new System.Threading.Thread(() =>
{
int r = AllocConsole();
if (r == 0)
{
throw new InvalidOperationException("Can't AllocConsole!");
}
StreamWriter standardOutput = new StreamWriter(Console.OpenStandardOutput());
standardOutput.AutoFlush = true;
Console.SetOut(standardOutput);
//host.Options.RunAction = Microsoft.Scripting.Hosting.Shell.ConsoleHostOptions.Action.RunConsole;
m_pythonConsoleHost.Run(new string[] { "-X:ColorfulConsole", "-X:Debug", "-X:TabCompletion", "-X:ExceptionDetail", "-X:ShowClrExceptions" }); //
//are.Set();
m_pythonConsoleHost.Runtime.IO.RedirectToConsole();
IronPython.Runtime.ClrModule.SetCommandDispatcher(IronPython.Runtime.DefaultContext.Default, null);
r = FreeConsole();
if (r == 0)
{
throw new InvalidOperationException("Can't FreeConsole!");
}
m_pythonConsoleHost = null;
});
_debugThread.IsBackground = true;
_debugThread.SetApartmentState(System.Threading.ApartmentState.STA);
_debugThread.Start();
// Don't establish the alternative input execution behavior until the other thread is ready. Note, 'are' starts out unsignalled.
//are.WaitOne();
while (m_pythonConsoleHost.ScriptScope == null)
{
System.Threading.Thread.Sleep(1000);
}
IronPython.Runtime.ClrModule.SetCommandDispatcher(IronPython.Runtime.DefaultContext.Default, DispatchConsoleCommand);
}
return m_pythonConsoleHost;
}
开发者ID:urmilaNominate,项目名称:mERP-framework,代码行数:56,代码来源:PythonConsoleHost.cs
示例12: GivenIHaveAServer
public void GivenIHaveAServer()
{
var wait = new System.Threading.AutoResetEvent(false);
var server = ScenarioContext.Current.Get<System.ServiceModel.ServiceHost>();
server.Opened += (sender, args) => wait.Set();
server.Open();
Assert.IsTrue(wait.WaitOne(TimeSpan.FromSeconds(1)));
}
开发者ID:MatthewChudleigh,项目名称:solipsist,代码行数:10,代码来源:Server.cs
示例13: GlibSync
// Sync up with the GLib thread. Should be called after the
// name, role, or parent are changed in UiaAtkBridge when
// checking for events, since we defer to an idle
// handler to call atk to avoid deadlock when atk
// emits signals. Called by RunInGuiThread in
// UiaAtkBridge.
public static void GlibSync ()
{
System.Threading.AutoResetEvent sync = new System.Threading.AutoResetEvent (false);
GLib.Timeout.Add (0, new GLib.TimeoutHandler (delegate {
sync.Set ();
return false;
}));
sync.WaitOne ();
sync.Close ();
}
开发者ID:mono,项目名称:uia2atk,代码行数:16,代码来源:TestBase.cs
示例14: Control
public Control(string ServerAddress, int Port, ref CarverLab.Utility.Logger logger)
{
log = logger;
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);
}
开发者ID:CarverLab,项目名称:Oyster,代码行数:10,代码来源:Control.cs
示例15: Execute
/// <summary>
/// Exectute the command
/// </summary>
/// <param name="args"></param>
/// <param name="fromAgentID"></param>
/// <returns></returns>
public override string Execute(string[] args, UUID fromAgentID)
{
if (args.Length < 1)
{
return "Usage: viewnote [notecard asset uuid]";
}
UUID note;
if (!UUID.TryParse(args[0], out note))
{
return "First argument expected agent UUID.";
}
System.Threading.AutoResetEvent waitEvent = new System.Threading.AutoResetEvent(false);
System.Text.StringBuilder result = new System.Text.StringBuilder();
// define a delegate to handle the reply
AssetManager.AssetReceivedCallback del = delegate(AssetDownload transfer, Asset asset)
{
if (transfer.Success)
{
result.AppendFormat("Raw Notecard Data: " + System.Environment.NewLine + " {0}", Utils.BytesToString(asset.AssetData));
waitEvent.Set();
}
};
// verify asset is loaded in store
if (Client.Inventory.Store.Contains(note))
{
// retrieve asset from store
InventoryItem ii = (InventoryItem)Client.Inventory.Store[note];
// subscribe to reply event
Client.Assets.OnAssetReceived += del;
// make request for asset
Client.Assets.RequestInventoryAsset(ii, true);
// wait for reply or timeout
if (!waitEvent.WaitOne(10000, false))
{
result.Append("Timeout waiting for notecard to download.");
}
// unsubscribe from reply event
Client.Assets.OnAssetReceived -= del;
}
else
{
result.Append("Cannot find asset in inventory store, use 'i' to populate store");
}
// return results
return result.ToString();
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:61,代码来源:ViewNotecardCommand.cs
示例16: DebugProcess
public DebugProcess()
{
this.din = Console.In;
this.dout = Console.Out;
CmdSyncWait = new System.Threading.AutoResetEvent(false);
imodules = new List<ICorDebugModule>();
iappdomains = new List<ICorDebugAppDomain>();
iassemblies = new List<ICorDebugAssembly>();
ibreakpoints = new List<ICorDebugFunctionBreakpoint>();
}
开发者ID:erisonliang,项目名称:qizmt,代码行数:12,代码来源:Program.cs
示例17: compile
public static Assembly compile(this string pathToFileToCompile, bool generateDebugSymbols)
{
PublicDI.CurrentScript = pathToFileToCompile;
var csharpCompiler = new CSharp_FastCompiler();
csharpCompiler.generateDebugSymbols= generateDebugSymbols;
var compileProcess = new System.Threading.AutoResetEvent(false);
csharpCompiler.compileSourceCode(pathToFileToCompile.contents());
csharpCompiler.onCompileFail = () => compileProcess.Set();
csharpCompiler.onCompileOK = () => compileProcess.Set();
compileProcess.WaitOne();
return csharpCompiler.assembly();
}
开发者ID:pusp,项目名称:o2platform,代码行数:12,代码来源:FastCompiler_ExtensionMethods.cs
示例18: GivenIHaveAClient
public void GivenIHaveAClient(string endpoint)
{
var wait = new System.Threading.AutoResetEvent(false);
var client = new Wcf.ServiceClient(endpoint);
client.InnerChannel.Opened += (sender, args) => wait.Set();
client.Open();
Assert.IsTrue(wait.WaitOne(TimeSpan.FromSeconds(1)));
ScenarioContext.Current.Set(client);
}
开发者ID:MatthewChudleigh,项目名称:solipsist,代码行数:12,代码来源:Client.cs
示例19: Timer
public Timer(System.Threading.TimerCallback callback)
{
if(!Node.MainNode.Ok()) { //this will also create the mainNode, if needed
throw new Exception("Cannot use RosTimer without a working Node!");
}
this.sig = new System.Threading.AutoResetEvent(false);
this.callback = callback;
this.running = true;
this.paused = true;
this.t = new System.Threading.Thread(new System.Threading.ThreadStart(this.Run));
this.t.Start();
}
开发者ID:clearskiesph,项目名称:cn-roscs-ros-pkg,代码行数:12,代码来源:Timer.cs
示例20: Execute
public override string Execute(string[] args, UUID fromAgentID)
{
System.Threading.AutoResetEvent waitBalance = new System.Threading.AutoResetEvent(false);
EventHandler<BalanceEventArgs> del = delegate(object sender, BalanceEventArgs e) { waitBalance.Set(); };
Client.Self.MoneyBalance += del;
Client.Self.RequestBalance();
String result = "Timeout waiting for balance reply";
if (waitBalance.WaitOne(10000, false))
{
result = Client.ToString() + " has L$: " + Client.Self.Balance;
}
Client.Self.MoneyBalance -= del;
return result;
}
开发者ID:KSLcom,项目名称:Aurora-LibOMV,代码行数:15,代码来源:BalanceCommand.cs
注:本文中的System.Threading.AutoResetEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论