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?

Re: Running a winform from Scheduler by Herfried

Herfried
Tue Apr 26 12:08:37 CDT 2005

"Arne" <Arne@discussions.microsoft.com> schrieb:
> 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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Re: Running a winform from Scheduler by Arne

Arne
Tue Apr 26 13:52:01 CDT 2005

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.


"Herfried K. Wagner [MVP]" wrote:

> "Arne" <Arne@discussions.microsoft.com> schrieb:
> > 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.
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://classicvb.org/petition/>
>
>

Re: Running a winform from Scheduler by Arne

Arne
Tue Apr 26 13:54:07 CDT 2005

I can't use modules at all. I am writing in C# this time.

"Herfried K. Wagner [MVP]" wrote:

> "Arne" <Arne@discussions.microsoft.com> schrieb:
> > 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.
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://classicvb.org/petition/>
>
>

Re: Running a winform from Scheduler by Herfried

Herfried
Tue Apr 26 16:08:08 CDT 2005

"Arne" <Arne@discussions.microsoft.com> schrieb:
> 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'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>