Hello,
is it possible to manually raise the event Elapsed of the timer object ?
Vittorio 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/>
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/>
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
* "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/>
* "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/>
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/>
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
* "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/>
* "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/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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?
|
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!
|
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?
|
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...
|
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
| |
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?
|
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
|
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.
|
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();
|
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...
|
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,...
| |
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...
|
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...
|
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,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |