本文整理汇总了C#中EventHandler.BeginInvoke方法的典型用法代码示例。如果您正苦于以下问题:C# EventHandler.BeginInvoke方法的具体用法?C# EventHandler.BeginInvoke怎么用?C# EventHandler.BeginInvoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventHandler
的用法示例。
在下文中一共展示了EventHandler.BeginInvoke方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PosTest1
public bool PosTest1()
{
bool retVal = true;
String temp = TestLibrary.Generator.GetString(-55, false, 1, 255);
TestLibrary.TestFramework.BeginScenario("PosTest1:invoke the method BeginInvoke with all arguments null");
try
{
HelperEvent helperEvent = new HelperEvent();
EventHandler<HelperArgs> eventHandler = new EventHandler<HelperArgs>(setMessage);
IAsyncResult iAR = eventHandler.BeginInvoke(helperEvent, new HelperArgs(temp), null, null);
TestLibrary.TestFramework.LogError("001", "Expected NotSupportedException exception");
retVal = false;
}
catch (NotSupportedException)
{
// expected
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("002", "Unexpected exception:" + e);
retVal = false;
}
return retVal;
}
示例2: OnConnectionStatusChangedInternal
// we need this method instead of directly call OnConnectionStatusChanged
// because of deadlock which can happen if we initiate the call ( pressing Call button).
void OnConnectionStatusChangedInternal(object sender, ConnectionEventArgs e) {
EventHandler<ConnectionEventArgs> d = new EventHandler<ConnectionEventArgs>(OnConnectionStatusChanged);
if (e.Connection.Status == ConnectionStatus.Connected) {
_currentIncommingConnection = e.Connection;
if (!string.IsNullOrEmpty(_answerSoundFileName)) {
ThreadPool.QueueUserWorkItem(SendFile, e.Connection);
}
} else {
_currentIncommingConnection = null;
}
d.BeginInvoke(sender, e, null, null);
}
示例3: btnOk_Click
private void btnOk_Click(object sender, EventArgs e)
{
picSpinner.Show();
btnOk.Enabled = false;
EventHandler action = new EventHandler(StartCSVImport);
action.BeginInvoke((bool)((string)cmbPlaylist.SelectedItem != "-"), null, null, null);
}
示例4: BeginStart
/// <summary>
/// Start wiping asynchronously
/// </summary>
/// <param name="callback">The method to be called when the operation has been completed.</param>
/// <param name="state">The state object.</param>
public bool BeginStart(AsyncCallback callback, object state)
{
Debug.AssertNotNull(callback, "Callback method not defined");
if(items == null || items.Count == 0) {
return false;
}
// run the task on the ThreadPool
EventHandler e = new EventHandler(StartAsync);
endStartCalled = false;
e.BeginInvoke(null, null, callback, startEvent);
return true;
}
示例5: InvokeNewLineEvent
/// <summary> Helper function to Invoke or directly call event. </summary>
/// <param name="newLineHandler"> The event handler. </param>
/// <param name="newLineArgs"></param>
private void InvokeNewLineEvent(EventHandler<CommandEventArgs> newLineHandler, CommandEventArgs newLineArgs)
{
if (newLineHandler == null || (ControlToInvokeOn != null && ControlToInvokeOn.IsDisposed)) return;
if (ControlToInvokeOn != null )
{
//Asynchronously call on UI thread
try { ControlToInvokeOn.BeginInvoke((MethodInvoker)(() => newLineHandler(this, newLineArgs))); } catch { }
}
else
{
//Directly call
try { newLineHandler.BeginInvoke(this, newLineArgs, null, null); } catch { }
}
}
示例6: User_CommandPcs
protected override string User_CommandPcs(string cmd)
{
cmd = cmd.ToUpper();
string returnValue = "+1";
float value = base.CommandSetAnaylzer(cmd);
ScanModel scanModel = new ScanModel();
if (cmd.Contains("CENT"))
{
}
else if (cmd.Contains("SPAN"))
{
}
else if (cmd.Contains("BWID"))
{
}
else if (cmd.Contains("RES"))
{
}
else if (cmd.Contains("VID"))
{
}
else if (cmd.Contains("STAT"))
{
}
else if (cmd.Contains("STOP"))
{
}
else if (cmd.Contains("CALC:X"))
{
}
else if (cmd.Contains("CALC:Y?"))
{
EventHandler eh = new EventHandler(delegate {
base.ClsSRE();
//Operation
base.SetSRE();
});
eh.BeginInvoke(null,null,null,null);
returnValue = (-178.5).ToString();
}
Console.WriteLine(value.ToString());
return returnValue;
//return base.User_CommandPcs(cmd);
}
示例7: StartAsync
public void StartAsync()
{
EventHandler e = new EventHandler(StartImpl);
e.BeginInvoke(null, null, null, null);
}
示例8: OnConditionsMetAsync
/// <summary>
/// Calls OnConditionsMet on its own thread, which then raises the ConditionsMet event for each of the delegates wired up.
/// </summary>
protected virtual void OnConditionsMetAsync(object sender, ConditionsMetEventArgs e)
{
if (ConditionsMet != null)
{
EventHandler<ConditionsMetEventArgs> workerDelegate = new EventHandler<ConditionsMetEventArgs>(this.OnConditionsMet);
workerDelegate.BeginInvoke(sender, e,
new AsyncCallback(asyncResult => ((EventHandler<ConditionsMetEventArgs>)asyncResult.AsyncState).EndInvoke(asyncResult)),
workerDelegate);
}
}