473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 1510
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 to windows 2003 server the service doesnt interact...
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 as a user account I cannot get it to interact...
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 solve the problem: I am writing a windows...
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 application as a windows service. When the service...
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 service at all? Private oMain As Main ...
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 service like start, stop and pause but along...
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 events came into my service. (I did allowed the...
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 interact with desktop... checkbox in services...
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 move the service to a production server, it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.