Running a winform from Scheduler

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a winform that starts from the scheduler. It performs a task, prints a
status message on the screen on waits for the operator to terminate the
program by clicking on the exit icon in the upper right corner.
There is only one problem. When the program has terminated, scheduler thinks
it is still running! Is there a way I can use an exit code that the Scheduler
can pick up?
 
Arne said:
When the program has terminated, scheduler thinks
it is still running! Is there a way I can use an exit code that the
Scheduler
can pick up?

Add a new module to the project:

\\\
Public Module Program
Public Function Main(ByVal Args() As String) As Integer
For Each Arg As String In Args
MsgBox(Arg)
Next Arg
Application.Run(New MainForm())
If...Then
Return 1
Else
Return 2
...
End If
End Function
End Module
///

Select 'Sub Main' as startup object in the project properties.
 
Herfried,

I thought I would return 0 on success.
Actually my program starts from
static void Main()
{
}
so I can't return anything the OS.
I have tried Application.Exit() and that seems to work.

Arne.
 
Arne said:
I thought I would return 0 on success.
Actually my program starts from
static void Main()
{
}
so I can't return anything the OS.

You can make 'void Main' a function that returns an 'int'.
 
Back
Top