如何在 WCF 中使用 WaitHandle

本文关键字:WaitHandle WCF | 更新日期: 2023-09-27 18:35:06

>我确实有两个方法,如下所示

private void UpdateGrid(ServiceRef.GetCampaignInfoArrayCompletedEventArgs e)
{
  try
  {
    if (CampaignStatusGrid.DataSource == null || e == null || e.Result == null)
                return;
    UpdateLocalCampaignList(sManager.campinfotmp, e.Result, null);
    sManager.campinfo = DeepCopy(sManager.campinfotmp);
    int index = CampaignStatusView.FocusedRowHandle;
    CampaignStatusGrid.BeginInvoke(new MethodInvoker(delegate { CampaignStatusGrid.DataSource = sManager.campinfo; }));
    CampaignStatusGrid.BeginInvoke(new MethodInvoker(delegate { CampaignStatusView.FocusedRowHandle = index; }));
  }
  catch (Exception ex)
  {
    if (ex.InnerException != null && ex.InnerException.GetType() == typeof(System.ServiceModel.EndpointNotFoundException))
                Program.ReConnect();
     else
        MessageBox.Show(string.Format("Exception Message:'n{0}'n'nInnerException Message:'n{1}'n'nStackTrace:'n{2}",
                    ex.Message, ex.InnerException != null ? ex.InnerException.Message : "None", ex.StackTrace));
        }
}
private bool RunSSIS(string SsisPackagePath)
{
.....
}

第一种方法异步运行并更新 girdview 数据源,第二种方法直接由用户调用。我不使用任何线程任务。我的问题是,当我调用 RunSSIS 方法时,需要 5 到 20 分钟才能获得结果。但同时异步方法每 5 到 10 秒运行一次

我知道我应该在异步方法中使用某种 WaitHandle 来等待任何正在进行的调用,但我不知道如何。

谢谢

如何在 WCF 中使用 WaitHandle

我认为您可以将任务类与异步一起使用并等待。http://msdn.microsoft.com/en-us/library/system.threading.tasks.task%28v=vs.110%29.aspx