Full Threaded Shellicious

I couldn't resist adding some features to Shellicious. You can now run shell commands either asynchronously (as before) or synchronously, like so:

Private WithEvents _s As New Shell
Private _IsExecutionComplete As Boolean = False
Public Sub Main()
 _s.UseNewThread = True
_s.Execute("C:LongRunningConsoleApp.exe")
Do While Not _IsExecutionComplete
'-- do other work here..
Thread.Sleep(20)
Loop
Console.WriteLine("Exiting Sub Main()..")
Console.ReadLine()
End Sub
Private Sub OutputLine(ByVal LineText As String) Handles _s.OutputLine
Console.WriteLine(LineText)
End Sub
Private Sub ExecutionComplete(ByVal TimedOut As Boolean) _
Handles _s.ExecutionComplete
_IsExecutionComplete = True
Console.WriteLine("execution complete; did we time out? " & TimedOut)
If _s.ExitCode <> 0 Then
Console.WriteLine(_s.Error)
End If
Console.WriteLine(_s.ExecutionTime)
Console.WriteLine(_s.ExitCode)
End Sub

I updated the code in the original post. And this time I remembered to give the threads names, which always helps in debugging:

The thread 'ShellErrorThread' (0xca4) has exited with code 0 (0x0).
The thread 'ShellOutputThread' (0x934) has exited with code 0 (0x0).
The thread 'ShellLaunchThread' (0x5c0) has exited with code 0 (0x0).

So far so good. The synchronous behavior respects the same .MaximumWaitSeconds property as before, and there's a new .CancelExecution method if you want to bail out on demand.

Read more

Stay Gold, America

We are at an unprecedented point in American history, and I'm concerned we may lose sight of the American Dream.

By Jeff Atwood · · Comments

The Great Filter Comes For Us All

With a 13 billion year head start on evolution, why haven't any other forms of life in the universe contacted us by now? (Arrival is a fantastic movie. Watch it, but don't stop there - read the Story of Your Life novella it was based on

By Jeff Atwood · · Comments

I Fight For The Users

If you haven't been able to keep up with my blistering pace of one blog post per year, I don't blame you. There's a lot going on right now. It's a busy time. But let's pause and take a moment

By Jeff Atwood · · Comments

The 2030 Self-Driving Car Bet

It's my honor to announce that John Carmack and I have initiated a friendly bet of $10,000* to the 501(c)(3) charity of the winner’s choice: By January 1st, 2030, completely autonomous self-driving cars meeting SAE J3016 level 5 will be commercially available for passenger

By Jeff Atwood · · Comments