问题描述:

So I have a message queue that I want to start sending the messages but I want to wait sending the next message until the current message is via its own timer tick. I have a for loop that sends all pending messages but I'm not sure how to lock the loop until the current message timer ticks. Any ideas?

 var localData = _mt6006.MainData;

//The max signal strength is a value of 1560.

var percent = (int)(((double)localData.SignalStrength / 1560) * 100);

//Based on the signal quality we change the

//time it takes for messages to come in.

int interval = (int)((100 - percent) / 0.01) + 1000;

//We have a network connection, send or

//receive messages that are pending.

for (int i = 0; i < PendingOutgoingMsgs.Count; i++)

{

var msg = PendingOutgoingMsgs[0];

NetworkStatusWin.Update_Protocol(Constants.SendingMsgProtocol);

Update_Status_Field(Constants.SendingMsgProtocol);

var sendingDelay = new Timer { Interval = interval };

sendingDelay.Tick += (sender, args) => _mt6006.SendingMsgDelay(sendingDelay, msg, ncs, prefix, countryCode);

sendingDelay.Start();

}

相关阅读:
Top