If you are using .NET 4.5 it is really easy to do with async/await and a TaskCompletionSource and async/await. TaskCompletionSource<string> resultTcs = new TaskCompletionSource<string>(); private async Task<string> SendCommandAsync(string command) { serialPort1.Write(command); // send the command var timeout = Task.Delay(500); //Wait for either the task to finish or the timeout to...
c#,timer,stack-overflow,doevents
Your StackOverflowException is possibly caused by repeated presses of the button. That would cause the BeginMonitoringClick() method to be called recursively, which would eventually overflow the stack. Without seeing the rest of the code, it's impossible to know for sure. In code where DoEvents() is used once, it's not uncommon...
excel,vba,excel-vba,loops,doevents
How about changing your 'do until' loop to a 'for next' loop? Something like?... Sub rowinput() Dim lngInputStartRow As Long Dim lngInputEndRow As Long Dim row_number As Long lngInputStartRow = Range("A1").Value 'specify your input cell here lngInputEndRow = Range("A2").Value For row_number = lngInputStartRow To lngInputEndRow DoEvents Next row_number 'Then a...