Click here to Skip to main content
15,905,785 members
Home / Discussions / C#
   

C#

 
GeneralRe: Processing a German Cultured Excel file using C# Pin
Prasanna Kumar Pete25-Sep-08 22:14
Prasanna Kumar Pete25-Sep-08 22:14 
QuestionRe: Processing a German Cultured Excel file using C# Pin
HemJoshi25-Sep-08 22:47
HemJoshi25-Sep-08 22:47 
AnswerRe: Processing a German Cultured Excel file using C# Pin
HemJoshi25-Sep-08 22:48
HemJoshi25-Sep-08 22:48 
QuestionExport PDF file in C# Pin
r aa j24-Sep-08 18:33
r aa j24-Sep-08 18:33 
AnswerRe: Export PDF file in C# Pin
blackjack215024-Sep-08 22:29
blackjack215024-Sep-08 22:29 
Questionwierd wierd wierd exception Pin
nelsonpaixao24-Sep-08 13:51
nelsonpaixao24-Sep-08 13:51 
AnswerRe: wierd wierd wierd exception Pin
PIEBALDconsult24-Sep-08 17:15
mvePIEBALDconsult24-Sep-08 17:15 
AnswerRe: wierd wierd wierd exception Pin
DaveyM6924-Sep-08 23:26
professionalDaveyM6924-Sep-08 23:26 
As PiebaldConsult said - check that there are subscribers to the events before raising them.

The standard way is something like:
public delegate void Delegate_DriverPageInfo(string msg);
public event Delegate_DriverPageInfo Event_DriverPageInfo;
// Method or Property Setter etc...
public void YourMethod()
{
    // stuff
    // event needs raising
    OnEvent_DriverPageInfo("Message");
}
protected virtual void OnEvent_DriverPageInfo(string message)
{
    if (Event_DriverPageInfo != null)
        Event_DriverPageInfo(message);
}

It's actually more normal to have your own class that derives from event args and pass the message that way - but it's not neccesary, just the norm.
public class DriverPageInfoEventArgs : EventArgs
{
    public DriverPageInfoEventArgs(string message)
    {
        m_Message = message;
    }
    private string m_Message;
    public string Message
    {
        get{ return m_Message; }
    }
}
...
public delegate void Delegate_DriverPageInfo(object sender, DriverPageInfoEventArgs e);
public event Delegate_DriverPageInfo Event_DriverPageInfo;
public void YourMethod()
{
    // stuff
    // event needs raising
    DriverPageInfoEventArgs e = new DriverPageInfoEventArgs("Message");
    OnEvent_DriverPageInfo(e);
}
protected virtual void OnEvent_DriverPageInfo(DriverPageInfoEventArgs e)
{
    if (Event_DriverPageInfo != null)
        Event_DriverPageInfo(this, e);
}

Whichever way, the important thing is the null check in the OnEvent... method.

Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Expect everything to be hard and then enjoy the things that come easy. (code-frog)

GeneralRe: wierd wierd wierd exception Pin
nelsonpaixao25-Sep-08 13:32
nelsonpaixao25-Sep-08 13:32 
Questionwaiting SQL results and screen freezes Pin
mhp13024-Sep-08 10:01
mhp13024-Sep-08 10:01 
AnswerRe: waiting SQL results and screen freezes Pin
Paul Conrad24-Sep-08 11:13
professionalPaul Conrad24-Sep-08 11:13 
AnswerRe: waiting SQL results and screen freezes Pin
Anthony Mushrow24-Sep-08 12:37
professionalAnthony Mushrow24-Sep-08 12:37 
GeneralRe: waiting SQL results and screen freezes Pin
nelsonpaixao25-Sep-08 13:40
nelsonpaixao25-Sep-08 13:40 
QuestionProgressBar on filling a DataGrid Pin
CHLINDE24-Sep-08 9:41
CHLINDE24-Sep-08 9:41 
AnswerRe: ProgressBar on filling a DataGrid Pin
Dave Kreskowiak24-Sep-08 9:45
mveDave Kreskowiak24-Sep-08 9:45 
QuestionDatabase Pin
CodingYoshi24-Sep-08 8:36
CodingYoshi24-Sep-08 8:36 
AnswerRe: Database Pin
Wendelius24-Sep-08 8:45
mentorWendelius24-Sep-08 8:45 
AnswerRe: Database Pin
Paul Conrad24-Sep-08 8:47
professionalPaul Conrad24-Sep-08 8:47 
AnswerRe: Database Pin
Pete O'Hanlon24-Sep-08 9:31
mvePete O'Hanlon24-Sep-08 9:31 
AnswerRe: Database Pin
Giorgi Dalakishvili24-Sep-08 20:19
mentorGiorgi Dalakishvili24-Sep-08 20:19 
QuestionWinForm to PDA? Pin
NewToAspDotNet24-Sep-08 7:52
NewToAspDotNet24-Sep-08 7:52 
AnswerRe: WinForm to PDA? Pin
DaveyM6924-Sep-08 8:08
professionalDaveyM6924-Sep-08 8:08 
GeneralRe: WinForm to PDA? Pin
NewToAspDotNet24-Sep-08 22:55
NewToAspDotNet24-Sep-08 22:55 
GeneralRe: WinForm to PDA? Pin
DaveyM6925-Sep-08 8:07
professionalDaveyM6925-Sep-08 8:07 
GeneralRe: WinForm to PDA? Pin
NewToAspDotNet25-Sep-08 13:10
NewToAspDotNet25-Sep-08 13:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.