您好,
我有一些异步方法(如web请求),需要在一系列命令之间调用。我需要子命令同步运行,因此无法使用CommandAsync(),因为子命令具有用户交互,我希望等待所有这些都完成(子命令例如可以获得选择集)
Autodesk.AutoCAD.Runtime。例外:eInvalidInput
示例:
- [CommandMethod("CMD_TEST")]
- public static async void CmdTest()
- {
- var activeDoc = Application.DocumentManager.MdiActiveDocument;
- Editor editor = activeDoc.Editor;
- await Task.Delay(100); // this could be e.g. some async web request in practice
- try
- {
- editor.Command("BCOUNT"); // some dummy command
- editor.WriteMessage("finished CMD_TEST\n");
- }
- catch (Exception ex)
- {
- editor.WriteMessage("failed CMD_TEST\n");
- }
- }
原因是什么,如何解决
为完整起见,以下是一个工作和非工作命令()调用的两个堆栈:
- > test_autocad.dll!Tools.AutoCAD.CommandsTest.CmdTestWorking()
- accoremgd.dll!Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(System.Reflection.MethodInfo mi, object commandObject, bool bLispFunction)
- accoremgd.dll!Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(System.Reflection.MethodInfo mi, object commandObject, bool bLispFunction)
- accoremgd.dll!Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()
- [Native to Managed Transition]
- accore.dll!CCmdThroat::arxCallNativeFunction()
- accore.dll!Command::doCommand()
- accore.dll!runTheCommand()
- accore.dll!CommandProcessor::mainCmdLoop()
- accore.dll!CCmdThroat::Run()
- accore.dll!AcApAppImp::internalRun()
- accore.dll!AcApAppImp::run(void)
- acad.exe!00007ff764026c41()
- mfc140u.dll!00007ff8109a3840()
- acad.exe!00007ff764039602()
- kernel32.dll!00007ff859ca7034()
- ntdll.dll!00007ff85b822651()
- > test_autocad.dll!Tools.AutoCAD.CommandsTest.CmdTestFailing()
- [Resuming Async Method]
- mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
- mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
- mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run()
- mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0()
- mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0()
- mscorlib.dll!System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.GetActionLogDelegate.AnonymousMethod__0()
- acpal.dll!00007fffe380d218()
- acpal.dll!00007fffe380d2e4()
- accore.dll!AcApAppImp::notifyMessagePreviewObservers(struct tagMSG &,bool)
- accore.dll!AcApApp::notifyMessagePreviewObservers(struct tagMSG &)
- acad.exe!CAcadApp::PreTranslateMessage()
- mfc140u.dll!AfxInternalPumpMessage()
- acad.exe!CAcadApp::PumpMessage(void)
- acad.exe!CAcadApp::runMessageLoop()
- accore.dll!AcApAppImp::runMessageLoop(void)
- accore.dll!win_event(void)
- accore.dll!CCmdThroat::select_device()
- accore.dll!CDig::digin()
- accore.dll!CAcCoreInput::GetRawInput()
- accore.dll!CAcCoreInput::egetdat()
- accore.dll!getCommandNameOrGripSelectionInput()
- accore.dll!CCmdThroat::Run()
- accore.dll!AcApAppImp::internalRun()
- accore.dll!AcApAppImp::run(void)
- acad.exe!CAcadApp::Run(void)
- mfc140u.dll!AfxWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow)
- acad.exe!__scrt_common_main_seh()
- kernel32.dll!BaseThreadInitThunk()
- ntdll.dll!RtlUserThreadStart()
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |