Blazor WebAssembly Monitor线程异常 [英] Blazor WebAssembly Monitor Threading exception

查看:58
本文介绍了Blazor WebAssembly Monitor线程异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发 .NET Standard 2.1 Blazor WebAssembly 托管应用程序.

I'm currently working on a .NET Standard 2.1 Blazor WebAssembly hosted application.

我的应用程序结构如下:

My application structure looks like this:

  • BlazorApp.Client(此处发生错误)
  • BlazorApp.Server

我在BlazorApp.Client项目中将Serilog与Elasticsearch接收器一起使用.它工作正常,但是当我在Serilog上启用 Selflog 并进行调试时,我在浏览器控制台中收到以下错误:

I use Serilog with the Elasticsearch sink in my BlazorApp.Client project. It works fine, but when I enable Selflog on Serilog and debug, I get the following error in my browser console:

SelfLog.Enable(msg => Debug.WriteLine(msg));

Elasticsearch.Net.UnexpectedElasticsearchClientException:无法在此运行时上等待监视器.--->System.Threading.SynchronizationLockException:无法在此运行时上等待监视器.

在(包装器托管到本机)System.Threading.Monitor.Monitor_wait(object,int)

,位于System.Threading.Monitor.ObjWait(System.Boolean exitContext,System.Int32毫秒超时,System.Object obj)< 0x36c60c8 + 0x00046>在:0

,位于System.Threading.Monitor.Wait(System.Object obj,System.Int32毫秒超时,System.Boolean exitContext)< 0x36c5de8 + 0x00022>在:0

在当前的Blazor WASm版本中,这似乎是一个问题: https://github.com/dotnet/aspnetcore/issues/22400

It seems to be an issue in the current Blazor WASm release: https://github.com/dotnet/aspnetcore/issues/22400

无法等待监视器有人知道,如何摆脱Blazor WebAssembly Client中的此错误?

Cannot Wait on monitors Does anyone know, how to possibly get rid of this error in Blazor WebAssembly Client?

推荐答案

您无法在Blazor WebAssembly中摆脱"该错误.WebAssembly代码(暂时)是单线程的,因此执行 System.Threading.Monitor.Wait(something); 将确保出现死锁.

You cannot 'get rid of' that error in Blazor WebAssembly. WebAssembly code is (for the time being) single-threaded so executing System.Threading.Monitor.Wait(something); would be a guaranteed deadlock.

该框架正确地向您表明此代码不适合WebAssembly.

The framework correctly signals to you that this code is not suitable for WebAssembly.

您将必须删除所有需要Wait()的代码.

You will have to get rid of of any code that needs to Wait().

这篇关于Blazor WebAssembly Monitor线程异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆