saul / demofile-net

Blazing fast cross-platform demo parser library for Counter-Strike 2 and Valve's Deadlock, written in C#.
MIT License
96 stars 8 forks source link

Usage from real-time application #22

Closed in0finite closed 9 months ago

in0finite commented 10 months ago

How would I use the library from real-time application which has it's own Message Loop (eg. GUI application) ?

Right now, the only way to parse demo file would be to call async method which would run in a different thread. It would be much better if the control of parsing is done by user of the library. That way, he can pause the parser, move to next tick, seek through history, etc.

Basically, a non-async version which allows the user to advance through demo file tick by tick.

I already implemented this myself (with additional API, no breaking changes), and would like to open PR, but I wanted to ask you what you think about it ?

saul commented 9 months ago

Here's a WIP PR - https://github.com/saul/demofile-net/pull/32. Are you still able to use async APIs? I've added ConfigureAwait(false) in all of the necessary places in the library, so you should be able to use them from WinForms now.

in0finite commented 9 months ago

Thank you for solving it so fast.

That PR looks excellent. I think that's all I need. Async APIs are fine.

Btw, this is my environment: I am trying to use the library in Unity engine. However, Unity can't run anything newer than .NET 4.8. So, in order to use the library I can either:

saul commented 9 months ago

Released as v0.8.1