Operation is not supported on this platform

vokxchh 2018-12-08 09:14:06

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace MahApps.Metro.netcoreapp30
{
public delegate void DoHandler();

public class Timeout
{
private ManualResetEvent mTimeoutObject;
//标记变量  
private bool mBoTimeout;

public DoHandler Do;

public Timeout()
{
//  初始状态为 停止  
this.mTimeoutObject = new ManualResetEvent(true);
}
///<summary>  
        /// 指定超时时间 异步执行某个方法  
        ///</summary>  
        ///<returns>执行 是否超时</returns>  
public bool DoWithTimeout(TimeSpan timeSpan)
{
if (this.Do == null)
{
return false;
}
this.mTimeoutObject.Reset();
this.mBoTimeout = true; //标记  
            this.Do.BeginInvoke(DoAsyncCallBack, null);
// 等待 信号Set  
if (!this.mTimeoutObject.WaitOne(timeSpan, false))
{
this.mBoTimeout = true;
}
return this.mBoTimeout;
}
///<summary>  
        /// 异步委托 回调函数  
        ///</summary>  
        ///<param name="result"></param>  
private void DoAsyncCallBack(IAsyncResult result)
{
try
{
this.Do.EndInvoke(result);
// 指示方法的执行未超时  
this.mBoTimeout = false;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
this.mBoTimeout = true;
}
finally
{
this.mTimeoutObject.Set();
}
}
}
}


this.Do.BeginInvoke(DoAsyncCallBack, null);
这行。net core 3.0报错,Operation is not supported on this platform 。之前wpf能正常用的。迁移不了了。。。
net core 不能委托吗?
...全文
2956 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
changuncle 2019-04-09
  • 打赏
  • 举报
回复
Core2.1中用Task代替委托进行异步操作可以正常执行,参考https://blog.csdn.net/xiaouncle/article/details/83037245
ilikeff8 2019-01-11
  • 打赏
  • 举报
回复
core只是个子集,很多功能都阉割了
APP开发王 2018-12-14
  • 打赏
  • 举报
回复
大胆尝试。。。。期待WPF 在.Net core 4.0 完美起来。。。。。。。。。。。
vokxchh 2018-12-13
  • 打赏
  • 举报
回复
改用CancellationTokenSource了。可以。
.net core 3.0 prev整体总感觉启动没有原来WPF快。同样的代码。
可能电脑太老了吧。
stherix 2018-12-10
  • 打赏
  • 举报
回复
现在.netcore还不支持WPF吧 coming sooooooon
threenewbee 2018-12-10
  • 打赏
  • 举报
回复
.net core不支持,只能用完整的框架了。
  • 打赏
  • 举报
回复
开始尝鲜core3.0 prev版本了?
  • 打赏
  • 举报
回复
不该用的就不要用。你选择迁移,说白了,就是要准备好放弃过去的技术成果。

13,346

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET技术前瞻
社区管理员
  • .NET技术前瞻社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧