C# News Ticker Multithreaded Application
Subject:   To make this work properly...
Date:   2003-09-12 07:37:49
From:   generalpf
Add this to the class:

private delegate void TickerDelegate(String s);
private TickerDelegate tickerDelegate1, tickerDelegate2;

In the constructor, add this:

tickerDelegate1 = new TickerDelegate(SetLeftTicker);
tickerDelegate2 = new TickerDelegate(SetRightTicker);

Add these functions to the class:

private void SetLeftTicker(String s)
label1.Text = s;
private void SetRightTicker(String s)
label2.Text = s;

And finally, replace "label1.Text =" with this:
label1.Invoke(tickerDelegate1,new object[] { headline.Substring(0,i) });

This is the proper way to do it.

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • To make this work properly...
    2003-11-05 17:08:57  anonymous2 [View]

    No 1: Get rid of the author!
    No 2: Congratulate generalpf on his/her example. Maybe you should have written this article and not some one who stumbled across threading yesterday.
  • To make this work properly...
    2003-09-12 07:39:00  generalpf [View]

    Oh yeah, and replace "label2.Text =" with this:
    label2.Invoke(tickerDelegate2,new object[] { headline.Substring(0,i) });

    ...but I'm sure you knew that.