带有命名管道的WPF和WCF

时间:2015-06-22 20:02:13

标签: c# wpf wcf named-pipes

以下代码在WinForms中运行良好:

if (System.Configuration.ConfigurationManager.AppSettings["Data.UseNamedPipes"] == "true") 
{
      AES.Cloud.DataAccessLayer.TheEDGEContext.UseLocalDb = true;
      string address = "net.pipe://localhost/" + Guid.NewGuid() + "/DataManager";
      var svc = AES.InProcFactory.CreateInstance<AES.Cloud.DataService.EstimatingDataService, AES.Cloud.DataService.IDataManager>(2147483647, 2147483647, address);
      DataService<AES.TheEdge.Framework.Services.Contracts.IDataManager>._namedPipeAddress = address;
      var ss = svc.GetNextKey();   //<-- Calling service here.
}     

但是当我使用WPF时,它在我调用服务时超时(底部异常,但它没用),但是如果我在另一个线程上调用此代码,它在WPF中工作得很好:

System.Threading.ThreadPool.QueueUserWorkItem( new System.Threading.WaitCallback( (o) =>{

    //same code as above...  no problem, no timeout, no blocking 
}

使用启动/主线程来执行此类操作是否存在问题?迷惑在木星......

例外:

System.TimeoutException: This request operation sent to net.pipe://localhost/c1a59720-11fc-49c3-9d82-8185203a6f5d/DataManager did not receive a reply within the configured timeout (00:01:00).  The time allotted to this operation may have been a portion of a longer timeout.  This may be because the service is still processing the operation or because the service was unable to send a reply message.  Please consider increasing the operation timeout (by casting the channel/proxy to IContextChannel and setting the OperationTimeout property) and ensure that the service is able to connect to the client.

0 个答案:

没有答案