473,386 Members | 1,773 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 Timers

Hi all,

I want to upload data at regular intervals, for that I used windows service with timer. Now problem is when I start my service. Its showing System.IO.IOException error. can any one help me, how to solve this
Dec 4 '09 #1
8 1469
MrMancunian
569 Expert 512MB
Wow, that's hard without seeing a piece of code or more explaination. All I can think of is that the service is trying to write something to a logfile that cannot be reached???

Steven
Dec 4 '09 #2
Expand|Select|Wrap|Line Numbers
  1. Private oTimer As System.Threading.Timer
  2.  
  3.     Protected Overrides Sub OnStart(ByVal args() As String)
  4.         Dim oCallback As New TimerCallback(AddressOf OnTimedEvent)
  5.         oTimer = New System.Threading.Timer(oCallback, Nothing, 0, 10000)
  6.  
  7.     End Sub
  8.  
  9.     Protected Overrides Sub OnStop()
  10.         ' Add code here to perform any tear-down necessary to stop your service.
  11.     End Sub
  12.     Private Sub OnTimedEvent(ByVal state As Object)
  13.  
  14.         Dim fs As FileStream = New FileStream("c:\1\mcWindowsService.txt", FileMode.OpenOrCreate, FileAccess.Write)
  15.         Dim m_streamWriter As StreamWriter = New StreamWriter(fs)
  16.         m_streamWriter.BaseStream.Seek(0, SeekOrigin.End)
  17.         m_streamWriter.WriteLine(" mcWindowsService: Service Started " & Constants.vbLf & " at " & System.DateTime.Now.ToString)
  18.         m_streamWriter.Flush()
  19.  
  20.  
  21.     End Sub
  22.  
  23.  


I am getting message first time, for second tick it is showing error.
Dec 4 '09 #3
MrMancunian
569 Expert 512MB
Expand|Select|Wrap|Line Numbers
  1. Dim fs As FileStream = New FileStream("c:\1\mcWindowsService.txt", FileMode.OpenOrCreate, FileAccess.Write)
Does this path/file exist and do you have permissions to write?

Steven
Dec 4 '09 #4
I told for first time, it writes the file, for next interval it is showing system.io.ioexception.
Dec 4 '09 #5
MrMancunian
569 Expert 512MB
I don't like your attitude. I'm trying to help you here and if your posts would be in more understandable English, it would make things a lot easier...

Now, did you already try to put this in a normal vb.net app and use breakpoints to debug it?

Steven
Dec 4 '09 #6
Yes, I already tried. I was not getting any solution. so that I posted my question here. When I start my service, for the first time. It is working. output is coming in notepad. in second interval it is showing this debugging message.

If you really helpful, then it is great.......
Dec 4 '09 #7
Sorry boss,

I got the solution. actually the file is being used by another process. i forget to close the file. any way thanks for your cooperation.
Dec 4 '09 #8
Frinavale
9,735 Expert Mod 8TB
I was just about to recommend that you check to make sure that you are properly closing the file after you write to it but it looks like you already figured that out.

I'm glad to see that you've solved your problem.

-Frinny
Dec 7 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mustaq | last post by:
Hi I am unable to get Timer1_Tick event in Windows Service Application inspite of setting following things Timer1.enabled = True Timer1.interval = 1000 Let me know how to resolve Thanks &
4
by: Keith | last post by:
I'm in the same boat as the fellow who posted this message back in August: Title : Windows Service, How does one make a service "fail" properly? Author : Ross Bennett Group :...
3
by: Jacob Crossley | last post by:
Hello all. We have about 10 Window's services that we wrote in c#. We use them to process row's that we have queued up in various SQL tables. The services seem to hang at least once in any given...
3
by: Nathan Kovac | last post by:
I have a feeling I am missing something simple, but I just can't find it. Perhaps someone can give me a lead on where to look. I will describe the issue then post my code to the web service. My...
2
by: John David Thornton | last post by:
I've got a Windows Service class, and I put a System.Threading.Timer, and I've coded it as shown below. However, when I install the service and then start it in MMC, I get a peculiar message: ...
5
by: Tom | last post by:
Using multiple System.Timers.Timer objects in a Windows Service for performing multi-thread activities in a periodic fashion. Timers are AutoReset=false, to only have a single timer execution...
10
by: Ryan | last post by:
Hello everyone, I have made a service that starts timers when it starts. I have another windows form application that stops and starts the service. Do I need to deal with any started timers when...
8
by: Ollie Riches | last post by:
I'm looking into a production issue related to a windows service and System.Timers.Timer. The background is the windows service uses a System.Timers.Timer to periodically poll a directory location...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
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,...
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.