诊断的ObjectDisposedException

诊断的ObjectDisposedException

本文介绍了诊断的ObjectDisposedException"安全手柄已经关闭"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有被击中的消息



This happens as soon as I launch the application.

Sadly the stack trace is really unhelpful (see below). Is there any way for me to determine what call was being attempted asynchronously here?

Does DoAsyncCall() really imply an async method call?

解决方案

The problem was caused by my use of a using(){} block.

    using (WaitHandle handle = asyncResponse.AsyncWaitHandle)
    {
      asyncResponse.AsyncWaitHandle.WaitOne();
      string response = asyncRequest.EndInvoke(asyncResponse);
      asyncResponse.AsyncWaitHandle.Close();
      return response;
    }

When the calling thread is interrupted the using block is still calling Close on the WaitHandle.

这篇关于诊断的ObjectDisposedException"安全手柄已经关闭"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 01:51