{"action":"created","issue":{"url":"https://api.github.com/repos/vknet/vk/issues/211","repository_url":"https://api.github.com/repos/vknet/vk","labels_url":"https://api.github.com/repos/vknet/vk/issues/211/labels{/name}","comments_url":"https://api.github.com/repos/vknet/vk/issues/211/comments","events_url":"https://api.github.com/repos/vknet/vk/issues/211/events","html_url":"https://github.com/vknet/vk/issues/211","id":141624570,"number":211,"title":"И снова \"Too many requests per second.\"","user":{"login":"DaleTernes","id":16364624,"avatar_url":"https://avatars.githubusercontent.com/u/16364624?v=3","gravatar_id":"","url":"https://api.github.com/users/DaleTernes","html_url":"https://github.com/DaleTernes","followers_url":"https://api.github.com/users/DaleTernes/followers","following_url":"https://api.github.com/users/DaleTernes/following{/other_user}","gists_url":"https://api.github.com/users/DaleTernes/gists{/gist_id}","starred_url":"https://api.github.com/users/DaleTernes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaleTernes/subscriptions","organizations_url":"https://api.github.com/users/DaleTernes/orgs","repos_url":"https://api.github.com/users/DaleTernes/repos","events_url":"https://api.github.com/users/DaleTernes/events{/privacy}","received_events_url":"https://api.github.com/users/DaleTernes/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-03-17T15:52:16Z","updated_at":"2016-03-17T18:07:50Z","closed_at":"2016-03-17T17:57:34Z","body":"Снова надо править метод VkApi.Invoke ().\r\n`\r\nif (RequestsPerSecond > 0 && LastInvokeTime.HasValue)\r\n\r\n            {\r\n                lock (_expireTimer)\r\n                {\r\n                    var span = LastInvokeTimeSpan.Value;\r\n                    LastInvokeTime = DateTimeOffset.Now;\r\n                    if (span.TotalMilliseconds < _minInterval)\r\n                    {\r\n                        Thread.Sleep(_minInterval - (int)span.TotalMilliseconds);\r\n                    }\r\n                    \r\n                }\r\n            }`\r\n\r\nLastInvokeTime присваивается до Thread.Sleep и следующий запрос опирается на некорректное время отправки предыдущего. \r\n\r\nНо, исправив этот недочёт у себя, я всё равно (хоть и редко) получаю \"Too many requests per second\"...\r\nУ меня один выход - поставить 2 в RequestsPerSecond, вместо 3.\r\nНо это медленно! Нужна возможность выставлять _minInterval снаружи, либо RequestsPerSecond сделать не целочисленным."},"comment":{"url":"https://api.github.com/repos/vknet/vk/issues/comments/198007936","html_url":"https://github.com/vknet/vk/issues/211#issuecomment-198007936","issue_url":"https://api.github.com/repos/vknet/vk/issues/211","id":198007936,"user":{"login":"kkohno","id":17728172,"avatar_url":"https://avatars.githubusercontent.com/u/17728172?v=3","gravatar_id":"","url":"https://api.github.com/users/kkohno","html_url":"https://github.com/kkohno","followers_url":"https://api.github.com/users/kkohno/followers","following_url":"https://api.github.com/users/kkohno/following{/other_user}","gists_url":"https://api.github.com/users/kkohno/gists{/gist_id}","starred_url":"https://api.github.com/users/kkohno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kkohno/subscriptions","organizations_url":"https://api.github.com/users/kkohno/orgs","repos_url":"https://api.github.com/users/kkohno/repos","events_url":"https://api.github.com/users/kkohno/events{/privacy}","received_events_url":"https://api.github.com/users/kkohno/received_events","type":"User","site_admin":false},"created_at":"2016-03-17T18:07:50Z","updated_at":"2016-03-17T18:07:50Z","body":"кстати если экземпляр обработчика равен null то либа чтобы работала как сейчас к примеру"}}