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

raising events

Hi All,

I'm I correct that you cannot raise events in the New (or constructor)
procedure?

Marcel
Nov 20 '05 #1
4 1052
"Marcel van der Gragt" <marcelASTvandergragtDTnl> wrote in message
news:e4**************@TK2MSFTNGP10.phx.gbl...
.. . .
I'm I correct that you cannot raise events in the New (or constructor)
procedure?


I believe so.
In order to catch an Event from an Object, you have to have a
reference to the object doing the Throwing. You won't have one
until the Object's constructor has completed.

HTH,
Phill W.
Nov 20 '05 #2
What about static events?

=)

"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
news:bu**********@yarrow.open.ac.uk...
"Marcel van der Gragt" <marcelASTvandergragtDTnl> wrote in message
news:e4**************@TK2MSFTNGP10.phx.gbl...
. . .
I'm I correct that you cannot raise events in the New (or constructor)
procedure?


I believe so.
In order to catch an Event from an Object, you have to have a
reference to the object doing the Throwing. You won't have one
until the Object's constructor has completed.

HTH,
Phill W.

Nov 20 '05 #3
"Marcel van der Gragt" <marcelASTvandergragtDTnl> schrieb

I'm I correct that you cannot raise events in the New (or
constructor) procedure?


You can raise events in the constructor. The problem is that you have to
1. create the object
2. add event handlers

As "create the object" includes the execution of the constructor, the first
handler can not be added before the constructor has been executed completely.
Consequently, no event handler will be called when the event is raised in
the ctor.

One exception:
1. Pass a delegate to the constructor
2. In the ctor, add the delegate to the event
3. raise the event

But, it's easier to simply invoke the delegate.

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
Nov 20 '05 #4
* "Armin Zingler" <az*******@freenet.de> scripsit:
I'm I correct that you cannot raise events in the New (or
constructor) procedure?


Yes. There are no handlers added at this time.

<http://www.google.de/groups?q=dotnet+vb+constructor+raise+event&ie=UTF-8&scoring=d>

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

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

Similar topics

4
by: serge calderara | last post by:
Dear all, I have a class wich is raising events as normally it should do. having a form in the same assembly wich is catching those events works fne. Raise events gets catch normaly within the...
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...
4
by: rawCoder | last post by:
Hi all, How Can You Raise Events Asynchronously ? Now for the details ... I want to do inter modular communication using events in such a way that the contributing modules need not...
7
by: cider123 | last post by:
I'm coding a project using the following article as reference: http://www.codeproject.com/csharp/DynamicPluginManager.asp In this type of project, plugins are loaded dynamically into a Plugin...
0
by: Greg Park | last post by:
I have many user controls loading into a web page using Page.LoadControl However, I'm unable to figure out how to raise an event when a button is click or a check box is checked. I can have...
0
by: Joe Campbell | last post by:
I am encountering a problem raising WMI events from an asp.net application. The error received (as captured in the event log) is as follows: System.Runtime.InteropServices.COMException...
4
by: Dave A | last post by:
I am developing a somewhat complex component at the moment and coincidently I am also reading the Framework Design Guidelines book. After reading the section about event raising I have re-written...
2
by: Gman | last post by:
Hi, I have created a usercontrol, a grid control essentially. Within it I have a class: clsGridRecord. I have coded the events such that when a user clicks on the grid, say, the events occur on...
0
by: Apu Nahasapeemapetilon | last post by:
Suggestions on cross-posting this issue would be appreciated. I've got a C# .NET DLL (CLR v1.1) that raises events into its container. When the container is a .NET application, raising the...
7
by: Christian Cambier | last post by:
Hi, I have a textbox in a web user control. I then add the usercontrol to a web form. I also add a label in the web form. Now, when I press a key in the textbox, i want to display some text...
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: 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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
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...
0
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,...

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.