0

我正在尝试编写一个自定义 msbuild 任务来检查网站是否可用。但是当我的任务结束时,它会抛出带有以下堆栈跟踪的 ObjectDisposedException。

   at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
   at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
   at Microsoft.Win32.Win32Native.SetEvent(SafeWaitHandle handle)
   at System.Threading.EventWaitHandle.Set()
   at Microsoft.Build.Utilities.ToolTask.ReceiveStandardErrorOrOutputData(DataReceivedEventArgs e, Queue dataQueue, ManualResetEvent dataAvailableSignal)
   at Microsoft.Build.Utilities.ToolTask.ReceiveStandardOutputData(Object sender, DataReceivedEventArgs e)
   at System.Diagnostics.Process.OutputReadNotifyUser(String data)
   at System.Diagnostics.AsyncStreamReader.FlushMessageQueue()
   at System.Diagnostics.AsyncStreamReader.GetLinesFromStringBuilder()
   at System.Diagnostics.AsyncStreamReader.ReadBuffer(IAsyncResult ar)
   at System.Runtime.Remoting.Messaging.AsyncResult.SyncProcessMessage(IMessage msg)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
   at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.DoAsyncCall()
   at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)
   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

我不明白是什么导致了这种行为。

这是显示问题的最简单的代码片段。

public class CustomTask : Task {
    public override bool Execute() {
        Thread.Sleep(10000);
        return true;
    }
}
4

1 回答 1

0

好的,我找到了自己问题的答案。作为构建文件的一部分,我通过standalone.bat 启动了一个JBoss 实例,现在该文件会阻塞,但我需要继续构建,所以我做了以下操作。

<Exec Command="$(StartWithJavaHome)" 
      WorkingDirectory="$(JBossPath)" Timeout="2000" ContinueOnError="true"/>

哪个起作用了,它不再阻塞了。但是发生的事情是 Exec 命令正在处理,但 JBoss 实例仍在写入标准输出,从而导致我看到的错误。

于 2013-06-06T10:09:57.233 回答