|
-
Oct 5th, 2007, 05:02 AM
#1
Thread Starter
Hyperactive Member
Add form to a service
Hello,
I'm trying to open a form on the start event of a service.
The form opens when I start my service but is not accessable.
The form looks like it has been crashed.
Does anyone know how to open a form in a window service?
I've tried to open it through a thread but the form appears and then quickly disappears.
-
Oct 5th, 2007, 08:14 AM
#2
Re: Add form to a service
 Originally Posted by HWijngaarD
Does anyone know how to open a form in a window service?
You don't. Windows Services don't have UI's.
You can create a service control program that communicates with a service though.
-
Oct 5th, 2007, 08:26 AM
#3
Re: Add form to a service
Actually it can be done.
You must use threads and you must allow the service to interact with the desktop. Services run on a different background and thats why you get your error.
It's real pain thought. Do it only if you REALLY must use a form like that.
A different approach will be to have the service pass a value to a resident program (windows application) and from there you can stimulate it to show the form. It's a lot easier.
-
Oct 5th, 2007, 01:26 PM
#4
Thread Starter
Hyperactive Member
Re: Add form to a service
I've got an application that monitors files through an filesystemwatcher (how new is that).
When a new file has saved it picks it up and transfers it to the database.
(linq to sql is really handy)
I got one form on it where I save my settings to my.settings.
Including the server and the database location.
Whould you (sapator) help me doing this?
I allready set the service to interact with the desktop.
When I put the form.show in a thread I can't keep it open.
When the threads gone the forms gone...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|