DateTime.Parse("AD3AD08")
[2017-08-03 12:00:00 AM]
Run Code Online (Sandbox Code Playgroud)
为什么这个字符串(看起来只是一个普通的十六进制字符串给我)作为日期成功解析?我可以看到3和8被解析为几个月和几天.但除此之外它对我没有意义.
我们有一个基于.NET Remoting的传统应用程序.我们的客户端客户端库目前仅支持同步操作.我想用基于TPL的async Task<>
方法添加异步操作.
作为概念证明,我已经基于这些指令的修改版本设置了基本的远程服务器/客户端解决方案.
我还发现这篇文章描述了如何将基于APM的异步操作转换为基于TPL的异步任务(使用Task.Factory.FromAsync
)
我不确定的是我是否被迫在其中指定回调函数.BeginInvoke()
并且还指定了.EndInvoke()
.如果两者都是必需的,回调函数与之间的区别究竟是什么.EndInvoke()
.如果只需要一个,我应该使用哪一个来返回值,并确保我没有内存泄漏.
这是我当前的代码,我没有将回调传递给.BeginInvoke()
:
public class Client : MarshalByRefObject
{
private IServiceClass service;
public delegate double TimeConsumingCallDelegate();
public void Configure()
{
RemotingConfiguration.Configure("client.exe.config", false);
var wellKnownClientTypeEntry = RemotingConfiguration.GetRegisteredWellKnownClientTypes()
.Single(wct => wct.ObjectType.Equals(typeof(IServiceClass)));
this.service = Activator.GetObject(typeof(IServiceClass), wellKnownClientTypeEntry.ObjectUrl) as IServiceClass;
}
public async Task<double> RemoteTimeConsumingRemoteCall()
{
var timeConsumingCallDelegate = new TimeConsumingCallDelegate(service.TimeConsumingRemoteCall);
return await Task.Factory.FromAsync
(
timeConsumingCallDelegate.BeginInvoke(null, null),
timeConsumingCallDelegate.EndInvoke
);
}
public async Task …
Run Code Online (Sandbox Code Playgroud)