Click here to Skip to main content
15,887,350 members
Home / Discussions / C#
   

C#

 
GeneralMessage Closed Pin
16-Oct-08 7:48
Hesham Yassin16-Oct-08 7:48 
GeneralRe: how to get a variable content from html body using C#? Pin
Paul Conrad16-Oct-08 7:49
professionalPaul Conrad16-Oct-08 7:49 
QuestionUpdating StatusStrip text from class Pin
Brad Wick16-Oct-08 5:47
Brad Wick16-Oct-08 5:47 
AnswerRe: Updating StatusStrip text from class Pin
Simon P Stevens16-Oct-08 6:02
Simon P Stevens16-Oct-08 6:02 
GeneralRe: Updating StatusStrip text from class Pin
Brad Wick16-Oct-08 6:36
Brad Wick16-Oct-08 6:36 
AnswerRe: Updating StatusStrip text from class Pin
Dirso16-Oct-08 6:55
Dirso16-Oct-08 6:55 
GeneralRe: Updating StatusStrip text from class Pin
DaveyM6916-Oct-08 7:07
professionalDaveyM6916-Oct-08 7:07 
AnswerRe: Updating StatusStrip text from class [modified] Pin
DaveyM6916-Oct-08 7:01
professionalDaveyM6916-Oct-08 7:01 
This is a perfect situation for using your own custom event. Something like this:

Create a delegate and event
public delegate void ConnectionChangedEventHandler(object sender, ConnectionEventArgs e);
public event ConnectionChangedEventHandler ConnectionChanged;

and a ConnectionEventArgs class
public class ConnectionEventArgs
{
    public ConnectionEventArgs(bool isConnected)
    {
        m_IsConnected = isConnected;
    }
    private bool m_IsConnected;
    public bool IsConnected
    {
        get { return m_IsConnected; }
    }
}

then make the InternetConnection call a method
private void InternetConnectionAvailable()
{
    OnConnectionChanged(new ConnectionEventArgs(true));
}
protected virtual void OnConnectionChanged(ConnectionEventArgs e)
{
    if (ConnectionChanged != null)
    ConnectionChanged(this, e);
}

Now you can subscribe to the ConnectionChanged event and update the StatusStrip
MyClassInstance.ConnectionChanged += new MyClass.ConnectionChangedEventHandler(MyClassInstance_ConnectionChanged);
void MyClassInstance_ConnectionChanged(object sender, ConnectionEventArgs e)
{
    // Set status strip
}


[edit] This is (obviously) also reusable for when it's not available too
private void InternetConnectionUnavailable()
{
    OnConnectionChanged(new ConnectionEventArgs(false));
}


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

modified on Thursday, October 16, 2008 1:07 PM

QuestionDistinguish between Keyboard and basic Barcode Scanner Pin
J-Cod3r16-Oct-08 4:50
J-Cod3r16-Oct-08 4:50 
AnswerRe: Distinguish between Keyboard and basic Barcode Scanner Pin
Simon P Stevens16-Oct-08 5:17
Simon P Stevens16-Oct-08 5:17 
AnswerRe: Distinguish between Keyboard and basic Barcode Scanner Pin
Brad Wick16-Oct-08 6:21
Brad Wick16-Oct-08 6:21 
GeneralRe: Distinguish between Keyboard and basic Barcode Scanner Pin
J-Cod3r16-Oct-08 20:24
J-Cod3r16-Oct-08 20:24 
GeneralRe: Distinguish between Keyboard and basic Barcode Scanner Pin
Brad Wick17-Oct-08 4:12
Brad Wick17-Oct-08 4:12 
AnswerRe: Distinguish between Keyboard and basic Barcode Scanner Pin
Dirso16-Oct-08 6:58
Dirso16-Oct-08 6:58 
AnswerRe: Distinguish between Keyboard and basic Barcode Scanner Pin
Dave Kreskowiak16-Oct-08 7:09
mveDave Kreskowiak16-Oct-08 7:09 
GeneralRe: Distinguish between Keyboard and basic Barcode Scanner Pin
Brad Wick17-Oct-08 12:49
Brad Wick17-Oct-08 12:49 
GeneralRe: Distinguish between Keyboard and basic Barcode Scanner Pin
Dave Kreskowiak17-Oct-08 16:35
mveDave Kreskowiak17-Oct-08 16:35 
QuestionSpeed Up Try Catch Pin
fly90416-Oct-08 4:36
fly90416-Oct-08 4:36 
AnswerRe: Speed Up Try Catch Pin
SeMartens16-Oct-08 4:49
SeMartens16-Oct-08 4:49 
AnswerRe: Speed Up Try Catch Pin
Paul Conrad16-Oct-08 9:24
professionalPaul Conrad16-Oct-08 9:24 
QuestionMSI Setup - custom action rollback Pin
Mogyi16-Oct-08 3:24
Mogyi16-Oct-08 3:24 
AnswerRe: MSI Setup - custom action rollback Pin
HemJoshi16-Oct-08 3:47
HemJoshi16-Oct-08 3:47 
GeneralRe: MSI Setup - custom action rollback Pin
Mogyi16-Oct-08 4:10
Mogyi16-Oct-08 4:10 
QuestionWhat is best way? Pin
Majid_grok16-Oct-08 2:45
Majid_grok16-Oct-08 2:45 
RantRe: What is best way? Pin
Nagy Vilmos16-Oct-08 3:06
professionalNagy Vilmos16-Oct-08 3:06 

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.