开发者

need to make a ticker that will also listen for incoming commands, but what style of multithreading to use?

I think I'm just going to use my already existing statusStrip. Text is all I need to work with so that'll make things easier. I want my ticker to rotate through a List<> or something, displaying each item for specified duration. I also want to be able to, at any time, call my ticker and get it to immediately display a string that I pass to it.

So, my question is which style of threading/thread pattern..etc? I've been reading here: http://www.albahari.com/threading and have been totally abso开发者_如何学编程rbed with this guy's work. I don't understand it all yet but I would like some suggestions to point me in the right direction...I've tried using Timer and it doesn't seem like the right approach...BackgroundWorker? I dunno, the thing doesn't really have to do much work..just display items on a loop....Any advice please?


You could have an observable class:

Ticker : IObservable<Ticker>
{
    // fulfill IObservable's contract
}

Then, a TickerReporter:

TickerReporter : IObserver<Ticker>
{
    // fulfill IObserver's contract
}

Where you would notify TickerReporter, use any number of asynchronous techniques to display the message. This is the IObserver<T>/IObservable<T> pattern.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜