{"action":"created","issue":{"url":"https://api.github.com/repos/NLog/NLog/issues/1853","repository_url":"https://api.github.com/repos/NLog/NLog","labels_url":"https://api.github.com/repos/NLog/NLog/issues/1853/labels{/name}","comments_url":"https://api.github.com/repos/NLog/NLog/issues/1853/comments","events_url":"https://api.github.com/repos/NLog/NLog/issues/1853/events","html_url":"https://github.com/NLog/NLog/pull/1853","id":195660166,"number":1853,"title":"AsyncTargetWrapper - Flush should start immediately without waiting","user":{"login":"snakefoot","id":11509660,"avatar_url":"https://avatars.githubusercontent.com/u/11509660?v=3","gravatar_id":"","url":"https://api.github.com/users/snakefoot","html_url":"https://github.com/snakefoot","followers_url":"https://api.github.com/users/snakefoot/followers","following_url":"https://api.github.com/users/snakefoot/following{/other_user}","gists_url":"https://api.github.com/users/snakefoot/gists{/gist_id}","starred_url":"https://api.github.com/users/snakefoot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snakefoot/subscriptions","organizations_url":"https://api.github.com/users/snakefoot/orgs","repos_url":"https://api.github.com/users/snakefoot/repos","events_url":"https://api.github.com/users/snakefoot/events{/privacy}","received_events_url":"https://api.github.com/users/snakefoot/received_events","type":"User","site_admin":false},"labels":[{"id":295599144,"url":"https://api.github.com/repos/NLog/NLog/labels/performance","name":"performance","color":"5319e7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/NLog/NLog/milestones/34","html_url":"https://github.com/NLog/NLog/milestone/34","labels_url":"https://api.github.com/repos/NLog/NLog/milestones/34/labels","id":2166959,"number":34,"title":"4.4.1","description":"","creator":{"login":"304NotModified","id":5808377,"avatar_url":"https://avatars.githubusercontent.com/u/5808377?v=3","gravatar_id":"","url":"https://api.github.com/users/304NotModified","html_url":"https://github.com/304NotModified","followers_url":"https://api.github.com/users/304NotModified/followers","following_url":"https://api.github.com/users/304NotModified/following{/other_user}","gists_url":"https://api.github.com/users/304NotModified/gists{/gist_id}","starred_url":"https://api.github.com/users/304NotModified/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/304NotModified/subscriptions","organizations_url":"https://api.github.com/users/304NotModified/orgs","repos_url":"https://api.github.com/users/304NotModified/repos","events_url":"https://api.github.com/users/304NotModified/events{/privacy}","received_events_url":"https://api.github.com/users/304NotModified/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":10,"state":"open","created_at":"2016-11-30T17:47:50Z","updated_at":"2016-12-21T20:58:43Z","due_on":null,"closed_at":null},"comments":7,"created_at":"2016-12-14T22:10:16Z","updated_at":"2016-12-21T21:16:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/NLog/NLog/pulls/1853","html_url":"https://github.com/NLog/NLog/pull/1853","diff_url":"https://github.com/NLog/NLog/pull/1853.diff","patch_url":"https://github.com/NLog/NLog/pull/1853.patch"},"body":"AsyncTargetWrapper has the following changes:\r\n\r\n- FlushAsync now schedules an \"instant\" QueueUserWorkItem, instead of waiting for the time-thread-event. Instead of waiting for all LogEvents to be written, then explicit Flush is called on WrappedTarget right after having written all pending logevents.  (minor breaking change)\r\n   - This means that putting a BufferingTargetWrapper inside \"targets async=true\" will no longer cause the AsyncTargetWrapper to wait for the BufferingTargetWrapper-flush-delay.\r\n    - This also means that Targets with broken Flush-method (not keeping track of pending logevents) will not get help from the AsyncTargetWrapper during flush.\r\n- CloseTarget now flushes all pending messages (instead of just the first BatchSize). CloseTarget-caller was also blocking before, so not much change here.\r\n\r\nBufferingTargetWrapper has the following changes:\r\n\r\n- FlushAsync now lets the WrappedTarget decide when it has flushed. Instead of waiting for all LogEvents to be written and then call explicit Flush on WrappedTarget. Flush-caller was also blocked before, so not much change here.\r\n    - This also means that Targets with broken Flush-method (not keeping track of pending logevents) will not get help from the BufferingTargetWrapper during flush.\r\n- CloseTarget now flushes any pending messages (minor breaking change, if not bugfix)\r\n- Do not hold Target.SyncRoot while writing messages on Timer-thread (Performance)\r\n\r\nReasons for these changes:\r\n- Closer alignment of AsyncTargetWrapper and BufferingTargetWrapper\r\n- Refactoring to increase the chance of making an instant flush on shutdown, without blocking the finalizer thread too much so it is terminated without anything written (See also #1846)\r\n- Could consider to change AsyncTargetWrapper.FlushAsync to perform synchrone flush instead of ThreadPool.QueueUserWorkItem, but then it would be a major breaking change, as the Flush-caller would be blocked while executing all the writes. (Would avoid spinning up new threads during shutdown, though this is already done by LogFactory.Flush)\r\n\r\nRelated issues in this area: #134 and #214\r\n\r\n<!-- Reviewable:start -->\r\n---\r\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/nlog/nlog/1853)\r\n<!-- Reviewable:end -->\r\n"},"comment":{"url":"https://api.github.com/repos/NLog/NLog/issues/comments/268641983","html_url":"https://github.com/NLog/NLog/pull/1853#issuecomment-268641983","issue_url":"https://api.github.com/repos/NLog/NLog/issues/1853","id":268641983,"user":{"login":"snakefoot","id":11509660,"avatar_url":"https://avatars.githubusercontent.com/u/11509660?v=3","gravatar_id":"","url":"https://api.github.com/users/snakefoot","html_url":"https://github.com/snakefoot","followers_url":"https://api.github.com/users/snakefoot/followers","following_url":"https://api.github.com/users/snakefoot/following{/other_user}","gists_url":"https://api.github.com/users/snakefoot/gists{/gist_id}","starred_url":"https://api.github.com/users/snakefoot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snakefoot/subscriptions","organizations_url":"https://api.github.com/users/snakefoot/orgs","repos_url":"https://api.github.com/users/snakefoot/repos","events_url":"https://api.github.com/users/snakefoot/events{/privacy}","received_events_url":"https://api.github.com/users/snakefoot/received_events","type":"User","site_admin":false},"created_at":"2016-12-21T21:16:31Z","updated_at":"2016-12-21T21:16:31Z","body":"> Fixes #1833 ?\r\n\r\nYes WriteEventsInQueue() now checks logEvents.Length before it writes."}}
{"actor":{"display_login":"snakefoot"}}