473,804 Members | 2,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Raise Timer_Elapsed event

Hello,
is it possible to manually raise the event Elapsed of the timer object ?

Vittorio
Nov 20 '05 #1
12 2946
* "Vittorio Pavesi" <n@spam.net> scripsit:
is it possible to manually raise the event Elapsed of the timer object ?


Place the code of the event handler in a separate method, then call this
method from within the event handler and any other place ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
Thank you for the workaround, this means that is not possible to raise that
kind of event ?

Vittorio

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> ha scritto nel
messaggio news:2k******** ****@uni-berlin.de...
* "Vittorio Pavesi" <n@spam.net> scripsit:
is it possible to manually raise the event Elapsed of the timer object ?


Place the code of the event handler in a separate method, then call this
method from within the event handler and any other place ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #3
Hi Vittorio,

You can not raise the event however call the method, as with every event.

As parameters you can normaly always pass (Nothing, Nothing)

I hope this helps,

Cor
Nov 20 '05 #4
* "Vittorio Pavesi" <n@spam.net> scripsit:
Thank you for the workaround, this means that is not possible to raise that
kind of event ?


It simply doesn't make much sense IMO.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5
* "Cor Ligthert" <no**********@p lanet.nl> scripsit:
You can not raise the event however call the method, as with every event.

As parameters you can normaly always pass (Nothing, Nothing)


This would call /one/ event handler, sure. Nevertheless, I don't think
that's a good idea, and placing the code of the handler in a separate
method would be the better approach.

If it's necessary to raise the event in certain situations, you can try
to inherit from the timer class and call the base class's
'On<EventName>' method to raise the event.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #6
Really thanks for the explanation !

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> ha scritto nel
messaggio news:2k******** ****@uni-berlin.de...
* "Vittorio Pavesi" <n@spam.net> scripsit:
Thank you for the workaround, this means that is not possible to raise that kind of event ?


It simply doesn't make much sense IMO.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #7
Hi Herfried,

This time I do *not* disagree with you, however it is possible.
This would mean that the first action would be to disable the timer.
However it was to show that you could do this with almost every event.

(Although for that handler method it would be probably the same, I think it
is not right doing this for a timer and certainly not for another timer than
the forms.timer, however just my thought).

:-)

Cor
Nov 20 '05 #8
* "Vittorio Pavesi" <n@spam.net> scripsit:
Really thanks for the explanation !


In other words: No, you cannot /raise/ an event from outside a class
except the class provides a method that raises the event internally. I
doubt that this is the case in the case of the timer.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #9
* "Cor Ligthert" <no**********@p lanet.nl> scripsit:
This time I do *not* disagree with you, however it is possible.
This would mean that the first action would be to disable the timer.
However it was to show that you could do this with almost every event.

(Although for that handler method it would be probably the same, I think it
is not right doing this for a timer and certainly not for another timer than
the forms.timer, however just my thought).


You /can/ call an event handler the way you showed, but I would not pass
'Nothing' to the parameters. Instead I would pass a reference to the
control the event is belonging to in the 'sender' parameter and
'EventArgs.Empt y' in the 2nd parameter.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #10

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

Similar topics

1
10522
by: Dan Cimpoiesu | last post by:
I have a remoting object, derived from MarshalByRefComponent, that I instantiate on the client side, with Activator.GetObject. Can I receive events fired on the server, on the client? How?
2
1605
by: IcedCrow | last post by:
Subject says it all. I want to raise an event in Sub New of a class but it is not being raised to my client app. I can raise events just fine in other procedures... just not sub new. Why is this? Thanks in advance!
4
4541
by: Jeremy | last post by:
I have a combobox with a SelectionChangeCommitted event handler, and am having a problem raising this event. For example, raiseEvent mycombobox.SelectionChangeCommitted gives me an error about not being ended properly. But it won't accept parameters either. What's the trick here?
8
2451
by: NewUser | last post by:
Hello, I'm a new user to Visual Basic.net and I would appreciate any help regarding a problem I have. I have searched the posts in this newsgroup and the VB library for threading topics, but I get confused with the code that is displayed. Anyway, I have a System.Timers.Timer object in a form and its interval is 50 ms. I want to create a thread around the Timer_Elapsed event (ie. myThread = new System.Threading.Thread(AddressOf...
2
2082
by: Pietro | last post by:
Hello, somebody know how to raise an event from a nested class? I have two classes, the class1 with 1 events, and a nested class (class2) inside the class1. So... How can I raise class1 events from the class2? Public Class class1 Public Shared Event Evento1(ByRef sender As Object) Public Class class2
1
9942
by: Anonieko | last post by:
I know Visual Studio lacked support on easily writing code to raise events from a ascx user control ( because you have to hand write them). (http://codebetter.com/blogs/brendan.tompkins/archive/2004/10/06/27795.aspx) Question: Is it better and easier now in ASPNET 2.0 , meaning VS 2005?
3
2137
by: =?Utf-8?B?Ulc=?= | last post by:
I constructed a new Class with some private members. I would like an event to be raised on the moment the value of one of those private members is changed. How do I define an event for that private member and how do I raise the event? -- RW
5
2015
by: Mike | last post by:
Hi group; Let say I have an object called Account, that raises an event called AccountLow with its owns EventArgs, and when this event gets raised, I will like to raise another custom event called AccountGotLowAmount and passes AccountLow’s EventArgs along with the new event.
2
9153
by: Sin Jeong-hun | last post by:
Suppose class Engine do something in another thread and raise events. class Engine { Thread Worker; public event ... EngineMessage; public void Start() { Worker=new Thread(new ThreadStart(Run)); Worker.Start();
0
9704
marktang
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...
0
9572
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,...
0
10562
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
10319
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
10303
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
5508
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...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2978
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.