# Issue: precise command timeout ```c# public int Execute_extended(ICommand command) { eRETURN_VALUES returnValue; if (IsInitialized) { eRETURN_VALUE threadReturnValue = eRETURN_VALUES.ETIMEOUT; using(AutoResetEvent autoResetEvent = new AutoResetEvent(false)) { Thread thread = new Thread(() => { try { threadReturnValue = (eRETURN_VALUES)command.Execute(); autoResetEvent.Set(); } catch (ThreadAbortException) { threadReturnValue = eRETURN_VALUES.ETIMEOUT; } finally { /* do cleanup */ } /* Rethrow of Exception */ }); thread.Start(); if(autoResetEvent.WaitOne(1000)) { /* procedure successful */ returnValue = threadReturnValue; } else { thread.Abort(); returnValue = eRETURN_VALUES.ETIMEOUT; } thread.Join(); } } else { Instance.Logger.LogError($"{(command as IInstrumentCommand).Device}: Device is not initialized"); returnValue = eRETURN_VALUES.NOTINITIALIZED; } return (int)returnValue; } ````
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up