472,352 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,352 software developers and data experts.

Windows Service that interacts with desktop

I am writing a service that I want to be able to display "debug" information on a desktop window. I have the following code that displays the form (when service is properly set up) and the service starts. However the form is not drawing itself completely and it is non responsive ("Not Responding" in the caption) and thus I can not see any information printed on it! I can stop the service and then the form is removed. Does anyone know why the form won't not respond?

Public Class FGDataService
Inherits System.ServiceProcess.ServiceBase

[Component Designer generated code]

Dim panel As InfoPanel
Protected Overrides Sub OnStart(ByVal args() As String)
'if the service can interact with desktop, then display log window
panel = New InfoPanel
panel.Visible = True
panel.txtInfo.Text += "Service Started"
End Sub
End Class
Nov 20 '05 #1
1 1467
The OnStart method is called on a thread pool thread. When that thread
completes the OnStart routine it returns to the ThreadPool code where it
waits on a synchronization object for more work to perform. So the thread
that creates the window never processes the messages in the window's message
queue. The thread that calls the OnStart routine should never do any work
other than some, small amount of initialization and setting up other threads
(either user created or threadpool threads) to perform the service's real
work.

If you wish to show a form on the interactive desktop (I assume this is for
debugging only, it really shouldn't be used for production code) you should
create a new thread and create the form object and call its ShowDialog
method on that thread so that the UI will have a dedicated thread. When
other threads in the service need to print messages on the UI then use
Control.Invoke (or BeginInvoke) on the form object to marshal the call to
the correct thread.
"RaggiHolm" <an*******@discussions.microsoft.com> wrote in message
news:B7**********************************@microsof t.com...
I am writing a service that I want to be able to display "debug" information on a desktop window. I have the following code that displays
the form (when service is properly set up) and the service starts. However
the form is not drawing itself completely and it is non responsive ("Not
Responding" in the caption) and thus I can not see any information printed
on it! I can stop the service and then the form is removed. Does anyone
know why the form won't not respond?
Public Class FGDataService
Inherits System.ServiceProcess.ServiceBase

[Component Designer generated code]

Dim panel As InfoPanel
Protected Overrides Sub OnStart(ByVal args() As String)
'if the service can interact with desktop, then display log window
panel = New InfoPanel
panel.Visible = True
panel.txtInfo.Text += "Service Started"
End Sub
End Class

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: cs | last post by:
I have a windows service that interacts with teh desktop, yes I know the consequences, anyways, the service works fine on winxp but when I move it...
6
by: Ian Frawley | last post by:
Hello everyone I have written a Windows Service to monitor local and remote Processes/Applications. However I am stuck because if it is installed...
3
by: Wolfgang Kutschera | last post by:
Greeting folks! This question has been asked before, but unfortunately never really been answeared. I would appreciate to get any clous on how to...
12
by: Noam | last post by:
I had originally written a program as a c# console application. The program used a reference that I wrote in c++. Later I was told to re-write the...
4
by: hex40 | last post by:
Hi, I have created a Service with vb.NET 2005 and I want to show a form. How can I do this? Can I do it like this? Or should'nt I use a form in a...
3
by: sonu | last post by:
Hello all, I am trying to develop an application which will run as a windows service. The application should have Normal options available with...
1
by: =?Utf-8?B?UmFmaQ==?= | last post by:
Hi, I made a 'windows services' which works well. When I added a notificaton icon, the icon apeared in the tray bar but when I clicked it, no...
2
by: christery | last post by:
Jippie, got my first c# service working with XP/W2003srv (love google), but got an hunch that vista will not support services that uses GUI (can...
41
by: pbd22 | last post by:
Hi. I know my windows service works when i run it in debug mode on my dev machine. It also works in release mode on my dev machine. But, when I...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.