我想知道如何使用 MarshalByRef 对象在服务器端处理线程。
鉴于我的远程 MarshalByRef 课程:
public class MyRemotedClass : MarshalByRef
{
public int MyInt;
public string MyString;
}
客户端代码(单线程):
MyRemotedClass m = GetSomehowMyRemotedClass();
m.MyInt = 5; // Write operation 1
m.MyString = "Hello World"; // Write operation 2
在服务器端,我们有两个写操作。我假设线程来自线程池。但是,由于该类是 MarshalByRef,因此两个操作都是单独的远程过程调用。他们会在单独的线程上运行吗?如果是,是否会在操作 1 完成之前执行操作 2?
PS:制作 MyRemotedClass MarshalByRef 是错误的决定。但我不能改变它,所以请不要提出这个建议。