473,830 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ServiceP rocess.ServiceB ase

[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.T ext += "Service Started"
End Sub
End Class
Nov 20 '05 #1
1 1528
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*******@disc ussions.microso ft.com> wrote in message
news:B7******** *************** ***********@mic rosoft.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.ServiceP rocess.ServiceB ase

[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.T ext += "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
1278
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 with the desktop anymore, I even have clicked the little thing that says that its ok to interact with the desktop, any idea what might be different?
6
1949
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 with the desktop and therefore get the System.Diagnostics.Process.Responding of an app. But if I set it as a System account that interacts with the desktop I have all sorts of security issues. I frigged the Type field within the Services registry...
3
2638
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 service that interacts with the desktop. (It shows a status dialog if a user is currently logged on.) To get this dialog shown correctly I need to have something like an application.doevents() call in my service. Is there anything like that
12
6535
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 would start up, as soon as it accessed the reference (by instantiating a class within the reference), the service would crash. In the event viewer I saw that it throw a System.IO.FileNotFoundException saying that the c++ reference was missing...
4
1395
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 Protected Overrides Sub OnStart(ByVal args() As String) ' Code zum Starten des Dienstes hier einfügen. Diese Methode sollte
3
7443
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 with this I need an option to show the windows application which my service has started as a result of its invokation. So I have written a service control by adding a new project of type
1
1858
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 service to intercat with the desktop). Can you tell me why I can't receive the events? Thank you -- Rafi Israel
2
1268
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 gone?), yepp (solution) can have 2 programs - one service and one normal GUI, just wondering if anything else changes in the near future? sort of a sneak peak into what trouble im haeding in to... gotta convert some vb6 code soon that is like that...
41
11674
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 exits immediately with a start/stop/nothing to do error. What could be wrong?
0
10477
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10522
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10197
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9310
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7740
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6944
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5615
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5777
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3072
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.