philiplcp Posted October 27, 2004 Posted October 27, 2004 I use vb.net to write a win service program, after finish installation, I switch on the service however it haven't any response so is there any way to solve it. Code: Service1.vb Protected Overrides Sub OnStart(ByVal args() As String) Timer1.Enabled = True End Sub Protected Overrides Sub OnStop() Timer1.Enabled = False End Sub Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed MsgBox("A") <-- show letter "A" at each second End Sub - Timer1 Property: Name: Timer1 AutoReset: True Enabled: False Interval: 1000 Modifiers: Friend ProjectInstaller.vb - ServiceInstaller1 Property: Name: ServiceInstaller1 DisplayName: ServiceTest Modifiers: Friend Parent: ProjectInstaller ServiceName: ServiceTest ServicesDependedOn: String[] StartType: Manual - ServiceProcessInstaller1 Property: Name: ServiceProcessInstaller1 Account: LocalSystem Modifiers: Friend Parent: ProjectInstaller Thank for your help (^_^) Quote
Administrators PlausiblyDamp Posted October 27, 2004 Administrators Posted October 27, 2004 I'm assuming the problem is that you aren't seeing the message box - correct? If so that is normal behaviour - services do not run within the logged on user's desktop (in fact the will run with no user logged in at all), this means they have there own desktop that just happens to never be displayed on screen - hence you cannot see the message box. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Mykre Posted October 28, 2004 Posted October 28, 2004 I'm assuming the problem is that you aren't seeing the message box - correct? If so that is normal behaviour - services do not run within the logged on user's desktop (in fact the will run with no user logged in at all)' date=' this means they have there own desktop that just happens to never be displayed on screen - hence you cannot see the message box.[/quote'] I would stop using the timer control from the toolbox (This needs a form to run), and start using the timer from the threading classes. There is an example of this on the quickstarts availible on gotdotnet.com on the toolbox menu on the left. There is also a basic service application. Quote Glenn "Mykre" Wilson, DirectX MVP Inner Realm Managed DirectX and Game Programming Resources
philiplcp Posted October 28, 2004 Author Posted October 28, 2004 thx for your help, I know how to solve the problem. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.