我已实施客户基础,以利用周转基金与服务连接。 然后,我呼吁在频道上采用与服务机构沟通的方法。
base.Channel.CalculateSomething();
这一呼吁是否安全,或者在接过多个线索时,我是否应该锁定?
增 编
我已实施客户基础,以利用周转基金与服务连接。 然后,我呼吁在频道上采用与服务机构沟通的方法。
base.Channel.CalculateSomething();
这一呼吁是否安全,或者在接过多个线索时,我是否应该锁定?
增 编
关于这里的答复的后续评论也我不确定,因此我感到有些愤慨。 http://blogs.msdn.com/b/rickrain/archive/2009/06wcf-instancing-concurrency-and-throttling-part-2.aspx。 该博客员额讨论了如何在一个用户代表处同时使用的单一用户代理的情况下适当开展全球合作框架服务。 (粗略强调:
...... 然而,如果适用以下条件,则可能增加对你服务的投入:
<client is multi-threaded, 并在使用同一代号的多个座右铭向您提供服务。
客户与服务之间的约束力是,具有约束力,会议。 (例如,净提贝制、高压/可靠会议、净重债等等)。
此外,这一职位的证据似乎与Brian的补充评论相矛盾,即WCF serializes 任何多面阅读的要求。 该员额显示了使用ConcurrencyMode.Multiple
和InstanceContextMode.PerCall
。
http://social.msdn.microsoft.com/Forums/vstudio/en-US/97258b67-4749-4af4-a5eb-87208c8e1f87/client-proxy-threadsafety?forum=wcf>here 这种做法对业绩的影响以及一些备选办法。
是的,它是read。 但是,你应当知道,世界合作框架将自动地把执行<代码>计算方法代码>的序号。 当使用同一<代码>ClientBase的不止一个读物时。 因此,如果你期望<代码>计算<>,则你必须重新思考你的设计。 查询 这一答案是为<代码>计算<>/代码>方法设定一个同步的APIC。
说到该频道上的方法是安全的(从客户的角度来看,服务取决于服务执行)。 你们可以把这种方法从多个侧面同时使用。 即便是汽车代理也为你提供制造同步电话的方法。
To Whom It May Concern. WCF Client base can be thread safe, at least in this configuration. I did not tried other configurations.
[ServiceContract(SessionMode = SessionMode.Required, CallbackContract = typeof(IWcfCallbacksContract), Namespace = "http://wcf.applicatin.srv/namespace")]
public interface IWcfContract
{
[OperationContract]
CompositeReturnObject GetServerObject();
}
服务:
public CompositeReturnObject GetServerObject()
{
CompositeReturnObject ret = new CompositeReturnObject("Hello");
Thread.Sleep(10000); // Simulating long call
return ret;
}
客户:
private void GetData_Click(object sender, RoutedEventArgs e)
{
Console.WriteLine("Task 1 start: " + DateTime.Now.ToString("HH:mm:ss"));
Task.Factory.StartNew(() => {
var res = _proxy.GetServerObject();
Console.WriteLine("Task 1 finish: " + DateTime.Now.ToString("HH:mm:s"));
Console.WriteLine(res.ToString());
return;
}
);
Thread.Sleep(2000);
Console.WriteLine("Task 2 start: " + DateTime.Now.ToString("HH:mm:ss"));
Task.Factory.StartNew(() => {
var res = _proxy.GetServerObject();
Console.WriteLine("Task 2 finish: " + DateTime.Now.ToString("HH:mm:s"));
Console.WriteLine(res.ToString());
return;
}
);
}
结果:
Task 1 start: 15:47:08
Task 2 start: 15:47:10Task 1 finish: 15:47:18
Name: Object one "Hello"Task 2 finish: 15:47:20
Name: Object one "Hello"
I have a simple silverlight multifile upload application, and i want to provide the user with some feedback, right now its only in a test phase and i dont have the webservice. Somehow i cant get the ...
I have several processes running concurrently that I want to log to the same file. We have been using Enterprise Library 4.1 Logging Application Block (with a RollingFlatFileTraceListener), and it ...
I was wondering if i could safely read from an XmlDocument object using SelectNodes() and SelectSingleNode() from multiple threads with no problems. MSDN says that they are not guaranteed to be ...
When a thread throws an exception that is unhandled, it terminates. What is the proper way to handle exceptions thrown on threads and how to propogate relevant exception data to other parts of the ...
My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...
So I m running perl 5.10 on a core 2 duo macbook pro compiled with threading support: usethreads=define, useithreads=define. I ve got a simple script to read 4 gzipped files containing aroud 750000 ...
I have created an Add-In in C# that implements user defined functions for Excel. These UDF s return immediately, but they control background asynchronous procedures. These procedures have status ...
I have a relatively simple question regarding the best way to call the DataGridView.Rows.Add function when it is inherited into the current control. Which is the best way to make the call to the ...