473,746 Members | 2,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Timers in c#

I have a C# program that have to run all the time. For
some reasons I cannot make it a service.
This program has 3 timers and by time to time ( days or
weeks) one of them stops. Some times, starts working again
after several hours.
Each timer records a message to a file at the beginning
and at the end of each timer.
I can see the last message from that timer and than
nothing.

I have to mention that in timer handler I'm using COM
objects written in C++ and another object of a .NET class
(include in project) that uses COM+ objects.

Thanks.
=============== =============== =============
private static System.Timers.T imer m_Timer1;
....
m_Timer1 = new System.Timers.T imer();
m_Timer1.Elapse d+=new ElapsedEventHan dler
(OnTimedEventPr ocessTimer1);
m_Timer1.Interv al = 1000;
m_Timer1.AutoRe set=false;
m_Timer1.Enable d=true;

......
protected void OnTimedEventPro cessTimer1(obje ct source,
ElapsedEventArg s e)
{
((System.Timers .Timer)source). Enabled=false;
bool b=false;
<...>.<...> myobj=null; //a COM object
try
{
....first message recorded
........
....last message recorded
}
catch (Exception ex)
{
}
finally
{
((System.Timers .Timer)source). Enabled=true;
((System.Timers .Timer)source). Start();
}
Nov 22 '05 #1
2 1853
Hi,

Could be that one of handlers is blocking?

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"GDumencu" <gd******@hotma il.com> wrote in message
news:01******** *************** *****@phx.gbl.. .
I have a C# program that have to run all the time. For
some reasons I cannot make it a service.
This program has 3 timers and by time to time ( days or
weeks) one of them stops. Some times, starts working again
after several hours.
Each timer records a message to a file at the beginning
and at the end of each timer.
I can see the last message from that timer and than
nothing.

I have to mention that in timer handler I'm using COM
objects written in C++ and another object of a .NET class
(include in project) that uses COM+ objects.

Thanks.
=============== =============== =============
private static System.Timers.T imer m_Timer1;
...
m_Timer1 = new System.Timers.T imer();
m_Timer1.Elapse d+=new ElapsedEventHan dler
(OnTimedEventPr ocessTimer1);
m_Timer1.Interv al = 1000;
m_Timer1.AutoRe set=false;
m_Timer1.Enable d=true;

.....
protected void OnTimedEventPro cessTimer1(obje ct source,
ElapsedEventArg s e)
{
((System.Timers .Timer)source). Enabled=false;
bool b=false;
<...>.<...> myobj=null; //a COM object
try
{
...first message recorded
.......
...last message recorded
}
catch (Exception ex)
{
}
finally
{
((System.Timers .Timer)source). Enabled=true;
((System.Timers .Timer)source). Start();
}

Nov 22 '05 #2
Hi,

Could be that one of handlers is blocking?

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"GDumencu" <gd******@hotma il.com> wrote in message
news:01******** *************** *****@phx.gbl.. .
I have a C# program that have to run all the time. For
some reasons I cannot make it a service.
This program has 3 timers and by time to time ( days or
weeks) one of them stops. Some times, starts working again
after several hours.
Each timer records a message to a file at the beginning
and at the end of each timer.
I can see the last message from that timer and than
nothing.

I have to mention that in timer handler I'm using COM
objects written in C++ and another object of a .NET class
(include in project) that uses COM+ objects.

Thanks.
=============== =============== =============
private static System.Timers.T imer m_Timer1;
...
m_Timer1 = new System.Timers.T imer();
m_Timer1.Elapse d+=new ElapsedEventHan dler
(OnTimedEventPr ocessTimer1);
m_Timer1.Interv al = 1000;
m_Timer1.AutoRe set=false;
m_Timer1.Enable d=true;

.....
protected void OnTimedEventPro cessTimer1(obje ct source,
ElapsedEventArg s e)
{
((System.Timers .Timer)source). Enabled=false;
bool b=false;
<...>.<...> myobj=null; //a COM object
try
{
...first message recorded
.......
...last message recorded
}
catch (Exception ex)
{
}
finally
{
((System.Timers .Timer)source). Enabled=true;
((System.Timers .Timer)source). Start();
}

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
371
by: GDumencu | last post by:
I have a C# program that have to run all the time. For some reasons I cannot make it a service. This program has 3 timers and by time to time ( days or weeks) one of them stops. Some times, starts working again after several hours. Each timer records a message to a file at the beginning and at the end of each timer. I can see the last message from that timer and than nothing.
0
1776
by: Dmitry Demchuk | last post by:
Hi everybody. Recently I ran into situation with System.Threading.Timer in my ASP.NET application. I reinstalled Windows on one of my servers and got timers stop firing events after while, they just stop functioning one-by-one. Here is detailed explanation. I run application on 2 dedicated Win 2003 servers. Server A serves about 1000 active simultaneous users (150-200 aspx page requests per second), Sever B serves about 400 users (80-100...
0
1769
by: Cider123 | last post by:
I was originally using: System.Windows.Forms.Timer It started to lock my Window Service up, so I went to the next evolution: System.Threading.Timer All was good. I was using it to send a message once a minute (to
3
2197
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 issue is simply getting timers to work. I have a DatabaseManager.DataManagerFacade which contains a timer. Every 6 seconds it updates stock data using an online webservice. I wrote have 2 possible startup projects to make the service work. One...
3
2038
by: Jeff Greenland | last post by:
Hello everyone, I am having problems with Timers in a web application. They just seem to stop running after 15 minutes or so. My web application is set up like this: When a user hits a page in the site, that page (.aspx) instantiates a compiled class (.DLL). The instantiation process creates a Timer that runs in the background to perform tasks every so often (such as notifying clients
9
7876
by: Mark Rae | last post by:
Hi, I've seen several articles about using System Timers in ASP.NET solutions, specifically setting them up in Global.asax' Application_OnStart event. I'm thinking about the scenario where I might need to carry out some back-end processing without pausing the individual users' Session while that process runs. E.g. I might provide the ability for a user to upload a text file of job
10
2706
by: WhiteSocksGuy | last post by:
Help! I am new to Visual Basic .Net (version 2002) and I am trying to get a System.Timers.Timer to work for me to display a splash screen for about two seconds and then load the main form. I have two forms (frmSplash and frmMain) and a code Module setup as my startup object. Here is the code that I have, when I try to run this part of the splash screen form shows and then program terminates. What am I doing wrong? Thanks,
5
9887
by: Michael C# | last post by:
Hi all, I set up a System.Timers.Time in my app. The code basically just updates the screen, but since the processing performed is so CPU-intensive, I wanted to make sure it gets updated regularly; like every 1.5 secs. or so. I only ran into one issue - the MyTimer_Elapsed event handler was not updating the screen correctly all the time, often leaving large chunks of the screen un-painted for several seconds. On a whim I decided to...
1
1827
by: | last post by:
Frustrated.. (I have seen other posts regarding this problem with no resolution..) I am using dotnet 1.1 with latest SP on a Win2KP box (actually 2 boxes), have even run the service on WinXP SP2 box.. I have created a service to grab data off a receive socket (small packets), place in a queue (Queue class), and do an insert into SQL. I have 3 timers in my project. One checks the status of the sql service every 15 seconds, one checks the...
1
3050
by: Jonathan Woods | last post by:
Hi there, I have three methods these need to execute at every interval time. I would like to know which option is better? Option A) Three System.Timers.Timer objects these execute each method. timer1.Elapsed += new System.Timers.ElapsedEventHandler(Method1_Elapsed);
0
9500
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, 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...
0
9349
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
9285
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
9218
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
8227
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
6772
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
6060
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();...
1
3292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2199
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.