本文整理汇总了C#中AsyncDelegate.BeginInvoke方法的典型用法代码示例。如果您正苦于以下问题:C# AsyncDelegate.BeginInvoke方法的具体用法?C# AsyncDelegate.BeginInvoke怎么用?C# AsyncDelegate.BeginInvoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AsyncDelegate
的用法示例。
在下文中一共展示了AsyncDelegate.BeginInvoke方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoExecuteMessageRequest
/// <summary>
/// 同步模式:处理
/// </summary>
/// <param name="msg"></param>
/// <returns></returns>
public override object DoExecuteMessageRequest(string serviceName, WQMessage msg, bool async)
{
//1. 保存DB,返回msg.TranscactionID
//2. 异步调用同步方法
//3. 开启守护线程修补失败的
Log.Write(LogAction.Info, className, "DoExecuteMessageRequest", serviceName, -1, string.Format(startFormat, serviceName, msg.TransactionID));
Routing routing = Routing(serviceName, msg);
if (null == routing || routing.EmptyHandlerName.Length > 0)
{
return EmptyRouting(serviceName, msg, async);
}
int rtn = -1;
msg.ServiceName = serviceName;
long pidx = routing.ParentGroupIndex;
long idx = routing.GroupIndex;
rtn = MessageDao.Save(serviceName, msg, (int)DealStatus.Dealing, pidx, idx);
Log.Write(LogAction.Info, className, "DoExecuteMessageRequest", serviceName, -1, msg.TransactionID + ",保存消息返回值:" + rtn);
if (rtn > 0)
{
AsyncDelegate ad = new AsyncDelegate(AsyncExecute);
ad.BeginInvoke(serviceName, pidx, idx, msg, null, null);
}
return (rtn > 0);
}
示例2: BeginExecuteNonQuery
/// <summary>
/// Initiates the asynchronous execution of the SQL statement or stored procedure
/// that is described by this <see cref="MySqlCommand"/>.
/// </summary>
/// <returns>An <see cref="IAsyncResult"/> that can be used to poll or wait for results,
/// or both; this value is also needed when invoking <see cref="EndExecuteNonQuery"/>,
/// which returns the number of affected rows. </returns>
public IAsyncResult BeginExecuteNonQuery()
{
if (caller != null)
Throw(new MySqlException(Resources.UnableToStartSecondAsyncOp));
caller = new AsyncDelegate(AsyncExecuteWrapper);
asyncResult = caller.BeginInvoke(2, CommandBehavior.Default, null, null);
return asyncResult;
}
示例3: BeginExecuteReader
/// <summary>
/// Initiates the asynchronous execution of the SQL statement or stored procedure
/// that is described by this <see cref="MySqlCommand"/> using one of the
/// <b>CommandBehavior</b> values.
/// </summary>
/// <param name="behavior">One of the <see cref="CommandBehavior"/> values, indicating
/// options for statement execution and data retrieval.</param>
/// <returns>An <see cref="IAsyncResult"/> that can be used to poll, wait for results,
/// or both; this value is also needed when invoking EndExecuteReader,
/// which returns a <see cref="MySqlDataReader"/> instance that can be used to retrieve
/// the returned rows. </returns>
public IAsyncResult BeginExecuteReader(CommandBehavior behavior)
{
if (caller != null)
Throw(new MySqlException(Resources.UnableToStartSecondAsyncOp));
caller = new AsyncDelegate(AsyncExecuteWrapper);
asyncResult = caller.BeginInvoke(1, behavior, null, null);
return asyncResult;
}
示例4: BeginExecuteNonQuery
/// <summary>
/// Initiates the asynchronous execution of the SQL statement or stored procedure
/// that is described by this <see cref="MySqlCommand"/>.
/// </summary>
/// <param name="callback">
/// An <see cref="AsyncCallback"/> delegate that is invoked when the command's
/// execution has completed. Pass a null reference (<b>Nothing</b> in Visual Basic)
/// to indicate that no callback is required.</param>
/// <param name="stateObject">A user-defined state object that is passed to the
/// callback procedure. Retrieve this object from within the callback procedure
/// using the <see cref="IAsyncResult.AsyncState"/> property.</param>
/// <returns>An <see cref="IAsyncResult"/> that can be used to poll or wait for results,
/// or both; this value is also needed when invoking <see cref="EndExecuteNonQuery"/>,
/// which returns the number of affected rows. </returns>
public IAsyncResult BeginExecuteNonQuery(AsyncCallback callback, object stateObject)
{
if (caller != null)
throw new MySqlException("ResourceStrings.UnableToStartSecondAsyncOp");
caller = new AsyncDelegate(AsyncExecuteWrapper);
asyncResult = caller.BeginInvoke(2, CommandBehavior.Default,
callback, stateObject);
return asyncResult;
}
示例5: Write
public static void Write(LogEvent log)
{
try
{
AsyncDelegate ad = new AsyncDelegate(write);
ad.BeginInvoke(log, new AsyncCallback(CallbackMethod), ad);
}
catch { }
}
示例6: OpenAttachmentAsync
public static void OpenAttachmentAsync(Control Ctrl, int AttachmentID, int ConnectionID)
{
Ctrl.UseWaitCursor = true;
// Create the delegate.
AsyncDelegate dlgt = new AsyncDelegate(Utils.OpenAttachment);
// Initiate the asychronous call. Include an AsyncCallback
// delegate representing the callback method, and the data
// needed to call EndInvoke.
IAsyncResult ar = dlgt.BeginInvoke(Ctrl, AttachmentID, ConnectionID, new AsyncCallback(CallbackMethod), dlgt);
}
示例7: BeginInvoke
protected void BeginInvoke(AsyncDelegate del)
{
del.BeginInvoke(EndInvoke, del);
}
示例8: BeginExecuteNonQuery
/// <summary>
/// Initiates the asynchronous execution of the SQL statement or stored procedure
/// that is described by this <see cref="MySqlCommand"/>.
/// </summary>
/// <returns>An <see cref="IAsyncResult"/> that can be used to poll or wait for results,
/// or both; this value is also needed when invoking <see cref="EndExecuteNonQuery"/>,
/// which returns the number of affected rows. </returns>
public IAsyncResult BeginExecuteNonQuery()
{
AsyncDelegate del = new AsyncDelegate(AsyncExecuteWrapper);
asyncResult = del.BeginInvoke(2, CommandBehavior.Default, null, null);
return asyncResult;
}
示例9: BeginExecuteReader
/// <summary>
/// Initiates the asynchronous execution of the SQL statement or stored procedure
/// that is described by this <see cref="MySqlCommand"/> using one of the
/// <b>CommandBehavior</b> values.
/// </summary>
/// <param name="behavior">One of the <see cref="CommandBehavior"/> values, indicating
/// options for statement execution and data retrieval.</param>
/// <returns>An <see cref="IAsyncResult"/> that can be used to poll, wait for results,
/// or both; this value is also needed when invoking EndExecuteReader,
/// which returns a <see cref="MySqlDataReader"/> instance that can be used to retrieve
/// the returned rows. </returns>
public IAsyncResult BeginExecuteReader(CommandBehavior behavior)
{
AsyncDelegate del = new AsyncDelegate(AsyncExecuteWrapper);
asyncResult = del.BeginInvoke(1, behavior, null, null);
return asyncResult;
}
示例10: BeginInvoke
protected void BeginInvoke(AsyncDelegate del)
{
// thread the delegate, as a fire and forget.
del.BeginInvoke(EndAsync, del);
}