本文整理汇总了C#中AsyncDelegate类的典型用法代码示例。如果您正苦于以下问题:C# AsyncDelegate类的具体用法?C# AsyncDelegate怎么用?C# AsyncDelegate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AsyncDelegate类属于命名空间,在下文中一共展示了AsyncDelegate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: BeginInvoke
public void BeginInvoke(AsyncDelegate del)
{
ControllerMainAction mainAction = new SimpleDefaultMainAction(this, del);
try
{
if (!View.IsHandleCreated)
{
return;
}
View.BeginInvoke(new AsyncDelegate(mainAction.run), null);
}
catch (ObjectDisposedException)
{
//happens because there is no synchronization between the lifecycle of a form and callbacks of background threads.
//catch silently
}
}
示例3: 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;
}
示例4: 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;
}
示例5: Write
public static void Write(LogEvent log)
{
try
{
AsyncDelegate ad = new AsyncDelegate(write);
ad.BeginInvoke(log, new AsyncCallback(CallbackMethod), ad);
}
catch { }
}
示例6: Invoke
public void Invoke(AsyncDelegate del)
{
Invoke(del, false);
}
示例7: Read
private void Read()
{
AsyncDelegate read = new AsyncDelegate(ReadAsync);
BeginInvoke(read);
}
示例8: BeginInvoke
protected void BeginInvoke(AsyncDelegate del)
{
del.BeginInvoke(EndInvoke, del);
}
示例9: Fail
private void Fail()
{
AsyncDelegate fail = new AsyncDelegate(FailAsync);
BeginInvoke(fail);
}
示例10: Freeze
private void Freeze()
{
AsyncDelegate freezeDelegate = new AsyncDelegate(FreezeAsync);
BeginInvoke(freezeDelegate);
}
示例11: Create
private void Create()
{
AsyncDelegate create = new AsyncDelegate(CreateAsync);
BeginInvoke(create);
}
示例12: Connect
private void Connect()
{
AsyncDelegate connect = new AsyncDelegate(ConnectAsync);
BeginInvoke(connect);
}
示例13: Commit
private void Commit()
{
AsyncDelegate commit = new AsyncDelegate(CommitAsync);
BeginInvoke(commit);
}
示例14: 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)
{
AsyncDelegate del = new AsyncDelegate(AsyncExecuteWrapper);
asyncResult = del.BeginInvoke(2, CommandBehavior.Default,
callback, stateObject);
return asyncResult;
}
示例15: Recover
private void Recover()
{
AsyncDelegate recover = new AsyncDelegate(RecoverAsync);
BeginInvoke(recover);
}