Running a winform from Scheduler

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?
 
H

Herfried K. Wagner [MVP]

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.
 
G

Guest

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.
 
H

Herfried K. Wagner [MVP]

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'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top