I wrote my Windows Service first as a regular Windows Exe because it is
easier to debug. In that I used
AppDir = Application.Exe cutablePath.Sub string(0,
Application.Exe cutablePath.Las tIndexOf("\")) ' Where this application
Excutable sits
Now, when I am converting it to a Service, what path can I use? Or can I
specify a path in the service to always use as a data path? I would prefer
the former because I do not know the layout of the target computer.
--
Anil Gupte www.keeninc.net www.icinema.com
Sep 13 '07
12 3711
How do I put a Sleep(15000) in there? Do I need to create a thread and then
use thread.sleep()?
Thanx,
--
Anil Gupte www.keeninc.net www.icinema.com
"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
news:fc******** **@south.jnrs.j a.net...
Anil Gupte wrote:
>1. My service will not even start. I tried putting a msgbox in the OnStart event to see if would do anything at all, but even that did not show. That means it is not even reaching the OnStart event.
Not necessarily.
If a Windows Service displays a MsgBox, it gets shown on a "virtual
desktop" that is reserved for system processes. No user can get to see
this "desktop", so the service process would seem to hang (this is why ASP
doesn't have a MsgBox function).
At least it used to - Windows may be "clever" enough now to catch the
MsgBox and write it into the Event log instead.
>I am sure it will run my main process fine if it gets there or at least I can start debugging - question is how to make it get there.
Put a Sleep(15000) into OnStart. That will give you enough time to attach
the debugger to the running [service] process when you start it.
>2. I do have a timer in the code, but I am not sure I want to kill it. I want the timer to start the main process every 10 minutes.
And if your "real" processing takes longer than 10 minutes, what then?
Do you want two instances of the routine running at the same time?
it will.
Personally, I /only/ use the Timer to "sidestep" out of OnStart and to
launch a continuously running process with Sleep call in it for the "gaps"
between bouts of doing stuff. I've had problems where a missing dependent
assembly can cause the Timer-invoked routine to fail to load but, since
this method is invoked from the innards of the Framework, there's no easy
way to catch the resulting Exception.
With a coded loop, a simple Try .. Catch does the job.
>Another thing, do I have to start the timer in the OnStart even of the service?
Yes. Start and Stop timers explicitly; that way you can clearly see
what's going on.
HTH,
Phill W.
Anil Gupte wrote:
How do I put a Sleep(15000) in there? Do I need to create a thread and then
use thread.sleep()?
You main process /is/ a thread.
System.Threadin g.Thread.Sleep( 15000 )
is all you need.
HTH,
Phill W.
Thanx! I fixed this problem anyway, but thanx for teaching me something new
(even though it is obvious to you, it is new to me :-))
--
Anil Gupte www.keeninc.net www.icinema.com
"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
news:fc******** **@south.jnrs.j a.net...
Anil Gupte wrote:
>How do I put a Sleep(15000) in there? Do I need to create a thread and then use thread.sleep()?
You main process /is/ a thread.
System.Threadin g.Thread.Sleep( 15000 )
is all you need.
HTH,
Phill W.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: |
last post by:
Hi,
I have a Windows Service that uses a referenced dotnet-dll.
In my dll I set some public string to a stringvalue that I
get from reading a xml-file(my config file). It works fine
if I use it in a vb-form. But since Windows Services ?
executes? in windows\system32 I can´t locate my xml-config-
file.
I don´t want to set different "compiling-statements" such
as :
|
by: bob |
last post by:
I have created a simple Windows service in VB.Net which installs fine
using InstallUtil.exe to install it to, for example "c:\test", or
"c:\Windows\YellowBanana", but if I install it to "c:\Program
Files\Test" it installs ok but will not start (no useful error message
is given other than the usual annoying suggestion about having
sufficient privileges).
The problem only seems to happen with spaces, not long filenames.
I have found a...
|
by: Laszlo Zsolt Nagy |
last post by:
Sorry, I realized that the import zlib was not executed from my
(working) service.
So here is the question: why can't I use zlib from a win32 service? Is
there any way to make it working?
>-------------
>Python could not import the service's module
> File "T:\Python\Projects\NamedConnector\Service.py", line 17, in ?
> from Processor import *
> File "c:\Python\Projects\NamedConnector\Processor.py", line 35, in ?
|
by: Gianfranco |
last post by:
Hi everybody,
First of all, sorry for my english if it isn't perfect ;-p
I have an error in an asp.net application.
I have win2003 server, with iis 6. I'm developping with visual studio
2005, vb.net, framework 2
I'm trying to access some binary files stored in C: in server2003. if i
|
by: Jim |
last post by:
I am writing a Windows Service in VB.Net, and right upfront I need to pass
the path to my config.xml file to the constructor of the class which reads
it. In the old days, App.Path & "\config.xml" would have done nicely. I have
tried using Reflection.Assembly.GetExecutingAssembly.Location but this is
horrible! I can't use the easy Application.Path property because it is a
service not a Forms application.
Is there a simple way to do this,...
| |
by: amit.vasu |
last post by:
Hi
I have created a web serivces using .net framework 2.0. When I try to
execute the web service I get the following error.
Failed to start monitoring changes to 'e:\Default Web Site' because
access is denied.
I am running windows 2003 sp1. Network Service account do have full
permission on application folder and sub folder.
|
by: Ronald |
last post by:
I just started with dotnetnuke, and with a wrong login (wrong password
on a clean install i can crash the application pool from IIS.
(when i login with the right username/password information the site
works fine, i can do anything it is supposed to do)
I have the following setup:
-Windows 2003 x64 (fully patched, clean install)
-Dotnetframework 2.0.50727
-Dotnetnuke 4.3.1
|
by: RMB |
last post by:
Environment: VS.Net 2003 FW 1.1 VB.Net
I have an application that uses reflection to load external assemblies. The
external assemblies reside in the same folder as the application exe. When I
run the application as a normal windows application, the external assemblies
are loaded just fine. When I run the application as a windows service, the
application expects the assemblies to be in the windows\system32 directory.
How can I change...
|
by: =?Utf-8?B?SmFtZXMgV29uZw==?= |
last post by:
Hi everybody,
I'm trying to use the new VB 2008 right now and I want to know how to preset
the company name and copyright informtion in Assembly Information. In my
current VB 2005, company name and copyright information (the word "CopyRight"
with company name and year) is filled in automatically once a new project is
created. However, I have no idea where I can configurate it in my new VB
2008.
Thanks for your kindly advice!
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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...
|
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();...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |