RusticiSoftware / TinCan.NET

C#/.NET library for Tin Can API
http://rusticisoftware.github.io/TinCan.NET/
Apache License 2.0
47 stars 57 forks source link

Asynchronous Support #13

Open svermeulen opened 9 years ago

svermeulen commented 9 years ago

I'm working on integrating this TinCan library into some software and am finding that it freezes briefly whenever I try writing some data to the LRS. Has there been any thought towards making this asynchronous? Ideally it could internally manage an ongoing queue of requests rather than blocking for each one.

brianjmiller commented 9 years ago

Considered, yes, but I can say it isn't on a roadmap nor does it have an expected date. It would be unlikely for us to add a queue structure to the library itself or implement a thread model since these things are usually very implementation specific and are better off handled by the application code than a library like this one. If you aren't in .NET 4.5 then I'd suggest managing an LRS thread(pool) yourself to deal with the blocking.

Having said that, my approach would likely use .NET 4.5's async/await capability through the HttpWebRequest. I've not looked into whether we could issue different dll's for the two versions or how that might look. I'm not too opposed to forcing people on to a newer version than 3.5, but they'd have to be getting something significant (which async might be enough to warrant).

To that end, pull requests are accepted if well conceived and hopefully with unit tests. The RemoteLRS class has a MakeSyncRequest abstraction already that could have a counterpart MakeAsyncRequest and it should be fairly straightforward to make the rest of the class compatible.

brianjmiller commented 9 years ago

I should have also included that we consider bounty based work on any of our OSS libs, if you want a defined approach and timeline.

svermeulen commented 9 years ago

Thanks Brian, I will experiment with different approaches and will probably end up changing the library a bit. If the result is something that I feel may have value for others I'll make a pull request.