c# - Throttle Messages Per Second -


i attempting throttle amount of messages send smpp smc(server). need throttle them smc not throttle , drop messages.

this have tried:

double _client.sendspeedlimit = 20; if (math.abs(_client.sendspeedlimit) > 1e-6 && _lastsubmit != datetime.minvalue) {     check submit speed , wait next time     double elapsed = (datetime.now - _lastsubmit).totalmilliseconds;     if (elapsed < 1000f / _client.sendspeedlimit)     {         int interval = convert.toint32((1000f / _client.sendspeedlimit) - elapsed);         thread.sleep(interval);              } } 

and...

int left = (int)(start.addseconds(1.0 / (double)_client.sendspeedlimit) - datetime.utcnow).totalmilliseconds; if (left > 0) {     mobiledal.inserterror(settings.default.mobileconnectionstring, "throttled: " + _clientfriendlyname, "", _accountid);     console.writeline("throttled: " + _clientfriendlyname, "", _accountid);     while (left > 0)     {         thread.sleep(10);         left = left - 10;     }     start = datetime.utcnow; } 

but dont seem work expected because still throttled service provider(smc). there wrong code? offer points of improvement?


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -