I need to raise events from a c# class to the caller, a c#
or vb form. In VB you would declare the event in the
class, then just use the RaiseEvent to raise the event, in
the form you would just create a handler that would handle
that event.
How do you do this same thing in c#? Is it possible to
raise events from a C# class to either a C# windows
application or a VB windows application?
Thanks
eric 4 5994 http://www.csharphelp.com/archives/archive51.html
"Eric" <en******@bpa.gov> wrote in message
news:12*****************************@phx.gbl... I need to raise events from a c# class to the caller, a c# or vb form. In VB you would declare the event in the class, then just use the RaiseEvent to raise the event, in the form you would just create a handler that would handle that event.
How do you do this same thing in c#? Is it possible to raise events from a C# class to either a C# windows application or a VB windows application?
Thanks eric
sure... but you aren't talking about events... you are talking about
exceptions.
Events are thrown by an object that another object subscribes to.
Exceptions are propogated up to the caller, like you describe.
create a class, derived from System.Exception, and give it a name.
Then, when you want to throw your "event", create a new object of your type
and "throw" it.
For further information, see http://msdn.microsoft.com/library/de...ctorTopic1.asp
Hope this helps,
-- Nick
"Eric" <en******@bpa.gov> wrote in message
news:12*****************************@phx.gbl... I need to raise events from a c# class to the caller, a c# or vb form. In VB you would declare the event in the class, then just use the RaiseEvent to raise the event, in the form you would just create a handler that would handle that event.
How do you do this same thing in c#? Is it possible to raise events from a C# class to either a C# windows application or a VB windows application?
Thanks eric
Thanks for all of the replies. I am familiar with
exceptions, i do want to raise an event. I have a
component that uses BeginReceive to monitor the message
queue, i want the component to raise an event to the
caller when there is a message in the queue. After a
little research i was able to get this figured out. It's
just a little more setup in C# vs. VB.
Thanks Again. -----Original Message-----
sure... but you aren't talking about events... you are
talking aboutexceptions. Events are thrown by an object that another object
subscribes to.Exceptions are propogated up to the caller, like you
describe. create a class, derived from System.Exception, and give
it a name.Then, when you want to throw your "event", create a new
object of your typeand "throw" it.
For further information, see http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpref/html/frlrfSystemExceptionClassctorTopic1.asp Hope this helps, -- Nick
"Eric" <en******@bpa.gov> wrote in message news:12*****************************@phx.gbl... I need to raise events from a c# class to the caller, a
c# or vb form. In VB you would declare the event in the class, then just use the RaiseEvent to raise the event,
in the form you would just create a handler that would
handle that event.
How do you do this same thing in c#? Is it possible to raise events from a C# class to either a C# windows application or a VB windows application?
Thanks eric
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sasha |
last post by:
Hi everyone,
Here is my problem:
I have the following classes:
- DataNode - this class is designed to hold some data and will be contained
in a tree like data structure DataTree. When...
|
by: Saso Zagoranski |
last post by:
Hi!
How can I unregister all the events registered to a control?
I have seen a piece of code in another thread, which gets all the registered
handlers for a specific event.
Let's say I have a...
|
by: JPRoot |
last post by:
Hi
I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using...
|
by: Bob Rundle |
last post by:
I have the following code, which appears to be working. However it doesn't
look right. The part I am wondering about is the logic in
DisconnectEvents(). This logic creates a new delegate and...
|
by: LP |
last post by:
Hello!
I am still transitioning from VB.NET to C#. I undertand the basic concepts
of Delegates, more so of Events and somewhat understand AsyncCallback
methods. But I need some clarification on...
|
by: Nicky Smith |
last post by:
Hello,
I'm studying a book on VB.net Win apps, and I'm reading a section on
events and delegates and raising events.
Is it just me, or is this not just subs dressed up as something else?
I...
|
by: Burkhard |
last post by:
Hi,
I am new to C# (with long year experience in C++) and I am a bit confused by
the language construct of events. What is it I can do with events that I
cannot do with delegates? At the moment...
|
by: Richard Maher |
last post by:
Hi,
Here I mean "User" in the Programmer or Javascript sense. I merely wish to
programmatically trigger an Event. It would be absolutely fantastic if there
was a (Form level?) ONUSEREVENT() and...
|
by: xoozlez |
last post by:
Hi there,
I have a registration form where I like to filter out the past events of 2007. This is the code I am using :
strSQL = "SELECT EventID, EventName, EventDateBegin, EventDateEnd,...
|
by: swethak |
last post by:
Hi,
I am desiging the calendar application for that purpose i used the below code. But it is for only displys calendar. And also i want to add the events to calendar. In that code displys the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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: 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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |