473,378 Members | 1,067 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,378 software developers and data experts.

Need Help With Timer

Hi, I'm new here and to c#. I have this minor problem with c#. The problem is that when the UpdateGui handler is fired, manager becomes null, even though it's static. Thanks in advance. Heres the code (simplified):

Expand|Select|Wrap|Line Numbers
  1. public partial class Form1 : Form
  2. {
  3.         static System.Timers.Timer myTimer;
  4.         static Manager manager;
  5.  
  6.         public Form1()
  7.         {
  8.             InitializeComponent();
  9.         }
  10.         private void Form1_Load(object sender, EventArgs e)
  11.         {
  12.             manager = new TorrentManager();
  13.             System.Timers.Timer myTimer = new System.Timers.Timer();
  14.             myTimer.Elapsed += new ElapsedEventHandler(UpdateGui);
  15.             myTimer.Interval = 5000;
  16.             myTimer.Start();
  17.         }
  18.         public static void UpdateGui(object source, ElapsedEventArgs e)
  19.         {
  20.            if (manager != null)
  21.            {
  22.            }
  23.         }
  24. }
Aug 22 '07 #1
1 1010
Shashi Sadasivan
1,435 Expert 1GB
Hi snareklutz
I could not replicate your problem.
Is your even being fider from other source too?
Aug 22 '07 #2

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

Similar topics

0
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...
4
by: Bilo | last post by:
I have a Windows Forms Class MainGUI I have declared MainGUI maingui; public System.ComponentModel.Container components = new Container(); in the Class I call another class MediaDriver with...
16
by: Crirus | last post by:
Hi there! This is the problem: I have a server that accept connections. Each request span a thread that handle it. I need a way to store the client IP's. If the requests made from a single IP...
10
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...
3
by: aprivate | last post by:
Hi I am having some problem with a form timer. I added a progress bar to increment its value and the timer works when I use form1.showdialog() However when I use form1.show, form1.refresh()...
5
by: Flack | last post by:
Hey guys, Here is what I am trying to achieve: I have a grid, and every once in a while the grid will receive a message to add a new row and highlight it (change the backcolor) for five...
4
by: Lemune | last post by:
Hello everyone. I'm using vb 2005. I'm creating program that run as service on windows. And in my program I need to use timer, so I'm using timer object from component. I try my source code on...
2
by: alxasa | last post by:
Hi, I have a setInterval which executes its command every 10 seconds in a infinite loop. I've got something real basic like: var processes=0; function startme(){ if(stopthisloop>1)
5
by: Peted | last post by:
i have an mdi application with two child forms Childform A and childform B in a nutshell Childform B has a timer with a routine that polls a ip socket for information every 30sec.
5
by: Andrew Hedges | last post by:
Wherein I attempt to debunk some myths about the relative merits of the two methods for programmatically adding content to a web page: ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.