Hi community, i been run into a lot of problems i can't solve when i use an alternative message pump, from events not firing till fields being altered on it's own and classes not being instantiated or not running correctly.
Since i don't want to use a Windows.Form and want my App to operate more or less similarly as a service but not completely. I have selected Windows Forms Application and disabled Application Framework, i have selected to start from a Module. And because my App needs a message pump i have written to not be closed by itself, rather operate like a Windows Form without a Window. I don't know what is the problem, maybe the Threads are conflicting, but then again there is no exception thrown. See the code:
Module Module1
Sub Main
Dim absClass As New InheritorClass()
End Sub
End Module
Class AbstractClass
Sub New()
Me.Start()
End Sub
WithEvents MainTimer As New System.Timers.Timer
Public Event Load()
Private Sub Start()
System.Console.WriteLine("Application has started.")
MainTimer.Interval = 5000
MainTimer.Start()
RaiseEvent Load()
Application.Run()
RaiseEvent Load()
End Sub
Sub Close()
System.Console.WriteLine("Application will exit.")
Application.Exit()
End Sub
Dim retriesLeft As Integer = 10
Private Sub MainTimer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles MainTimer.Elapsed
If retriesLeft > 0 Then
System.Console.WriteLine(String.Format("{0} retries remaining...", retriesLeft))
retriesLeft = retriesLeft - 1
Else
Me.Close()
End If
End Sub
End Class
Class InheritorClass : Inherits AbstractClass
Sub New()
MyBase.New()
End Sub
Private Sub Me_Load() Handles Me.Load
MsgBox("App has loaded")
End Sub
End Class
I have managed to modify the code to make it work using methods by directly calling but then some of the fields get altered or nullified on their own etc. Also calling other Classes from the InheritorClass is not possible.
What I have tried:
--------------------------------------------------------------------------------------