如何在c#中一个接一个地显示多个队列信息

时间:2017-04-05 15:20:48

标签: c# winforms user-interface client-server

c#(客户端 - 服务器窗体申请表):

鉴于我有多个来自服务器端的消息,我保存在列表/字典中。

如何逐个显示/弹出窗口信息? (例如,对于应用程序更新,您会看到通知)。对于一个messege show popup不是问题,但是当有多个消息时,事情变得复杂。

如何避免第二个(例如,最后一个)消息覆盖/替换第一个(较早的)消息的文本而用户只看到第二个(最后一个)消息文本的情况?

下面是我的做法:

// messages coming from server
// 1 : "test message 1"
// 2 : "test message 2"

// create update-recieved event 

 var e = new UpdateReceivedEventArgs(serverMessages);

// once the update from server is recieved ,  function should update the GUI for each server message, i.e, popup-window will appear for each server message, and user will do some interaction (e.g click ok) and program ends.

任何提示?示例代码?

1 个答案:

答案 0 :(得分:0)

I would create a class for handling your messages. When the server passes the messages, have it include a priority or message type as well so that your message handler class knows what should be done with it.

If the message is a notification then it can just show an icon notifying of updates, etc.

If the message is priority then a 'popup box' is required. If another message is received while the popup box is still visible you could append the message to the end of the other message to avoid the end user from clicking through multiple popup boxes.