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

How to declare timer?

If I use the following code, the declaration is fine.
//no namespace
private System.Timers.Timer Clock;

This gives the error, "'Timer' is an ambiguous reference".
using System.Timers; //namespace doesn't make a difference
....
private Timer Clock;

What am I doing wrong?

Thanks,
Brett
Nov 17 '05 #1
5 4534
In message <u6**************@tk2msftngp13.phx.gbl>, Brett <no@spam.com>
writes
If I use the following code, the declaration is fine.
//no namespace
private System.Timers.Timer Clock;

This gives the error, "'Timer' is an ambiguous reference".
using System.Timers; //namespace doesn't make a difference
...
private Timer Clock;

What am I doing wrong?


There's more than one class called "Timer" in the framework.

System.Threading.Timer
System.Timers.Timer
System.Windows.Forms.Timer

Maybe more.

You already have one in scope, and adding the using directive brings in
another.

--
Steve Walker
Nov 17 '05 #2

"Steve Walker" <st***@otolith.demon.co.uk> wrote in message
news:xV**************@otolith.demon.co.uk...
In message <u6**************@tk2msftngp13.phx.gbl>, Brett <no@spam.com>
writes
If I use the following code, the declaration is fine.
//no namespace
private System.Timers.Timer Clock;

This gives the error, "'Timer' is an ambiguous reference".
using System.Timers; //namespace doesn't make a difference
...
private Timer Clock;

What am I doing wrong?


There's more than one class called "Timer" in the framework.

System.Threading.Timer
System.Timers.Timer
System.Windows.Forms.Timer

Maybe more.

You already have one in scope, and adding the using directive brings in
another.

--
Steve Walker


I see. I am doing this which brings in two timers:
using System.Windows.Forms;
using System.Threading;

I could narrow down the Clock declaration by providing a full path. Is
there another way?

Thanks,
Brett
Nov 17 '05 #3
Problem is that Timer exists in System.Windows.Forms namespace as well.
I think you have declared using System.Windows.Forms and using System.Timers
at once.

"Brett" <no@spam.com> wrote in message
news:u6**************@tk2msftngp13.phx.gbl...
If I use the following code, the declaration is fine.
//no namespace
private System.Timers.Timer Clock;

This gives the error, "'Timer' is an ambiguous reference".
using System.Timers; //namespace doesn't make a difference
...
private Timer Clock;

What am I doing wrong?

Thanks,
Brett

Nov 17 '05 #4
In message <uC**************@TK2MSFTNGP10.phx.gbl>, Brett <no@spam.com>
writes

"Steve Walker" <st***@otolith.demon.co.uk> wrote in message
news:xV**************@otolith.demon.co.uk...
In message <u6**************@tk2msftngp13.phx.gbl>, Brett <no@spam.com>
writes
If I use the following code, the declaration is fine.
//no namespace
private System.Timers.Timer Clock;

This gives the error, "'Timer' is an ambiguous reference".
using System.Timers; //namespace doesn't make a difference
...
private Timer Clock;

What am I doing wrong?
There's more than one class called "Timer" in the framework.

System.Threading.Timer
System.Timers.Timer
System.Windows.Forms.Timer

Maybe more.

You already have one in scope, and adding the using directive brings in
another.

I see. I am doing this which brings in two timers:
using System.Windows.Forms;
using System.Threading;

I could narrow down the Clock declaration by providing a full path. Is
there another way?


You can alias namespaces like this:

using Stuff = System.Timers;
....
private Stuff.Timer Clock;

--
Steve Walker
Nov 17 '05 #5

"Steve Walker" <st***@otolith.demon.co.uk> wrote in message
news:Hz**************@otolith.demon.co.uk...
In message <uC**************@TK2MSFTNGP10.phx.gbl>, Brett <no@spam.com>
writes

"Steve Walker" <st***@otolith.demon.co.uk> wrote in message
news:xV**************@otolith.demon.co.uk...
In message <u6**************@tk2msftngp13.phx.gbl>, Brett <no@spam.com>
writes
If I use the following code, the declaration is fine.
//no namespace
private System.Timers.Timer Clock;

This gives the error, "'Timer' is an ambiguous reference".
using System.Timers; //namespace doesn't make a difference
...
private Timer Clock;

What am I doing wrong?

There's more than one class called "Timer" in the framework.

System.Threading.Timer
System.Timers.Timer
System.Windows.Forms.Timer

Maybe more.

You already have one in scope, and adding the using directive brings in
another.

I see. I am doing this which brings in two timers:
using System.Windows.Forms;
using System.Threading;

I could narrow down the Clock declaration by providing a full path. Is
there another way?


You can alias namespaces like this:

using Stuff = System.Timers;
...
private Stuff.Timer Clock;

--
Steve Walker


Ok, thanks.

Why if I do something like
this.IE_Inst.Stop();
C# will not automatically put the parentheses on Stop() so I get a compiler
error.

Brett
Nov 17 '05 #6

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

Similar topics

13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
2
by: DaveF | last post by:
I am trying to write a service to fire an ftp object off. I want to wait 2 minutes and then download the files. Then repeat every 2 minutes. The files just seem to stop downloading. Does that timer...
6
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a...
3
by: mjheitland | last post by:
Hi, I like to know how many threads are used by a Threading.Timer object. When I create a Threading.Timer object calling a short running method every 5 seconds I expected to have one additional...
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: ...
12
by: Gina_Marano | last post by:
I have created an array of timers (1-n). At first I just created windows form timers but I read that system timers are better for background work. The timers will just be monitoring different...
8
by: =?Utf-8?B?RGF2ZSBCb29rZXI=?= | last post by:
I have a Timer that I set to go off once a day, but it frequently fails! In order to debug I would like to be able to check, at any moment, whether the Timer is enabled and when it will next...
16
by: Peter Oliphant | last post by:
Note that although this involves SAPI, it is more a question about Timers and event handlers. I wrote a Speech Recognize handler (SAPI), and put some code in it to enable a Timer. It would not...
20
by: Sun | last post by:
Maybe this is a very primative question, but I just get a bit confused about 'set' and 'Set' module in python. I understand 'set' is a build in type in python after 2.4(or 2.3) and Set a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.