❔ SignalR for real-time REST api data in WPF?
Hey,
Im working on a hobby WPF application that needs to consume a rest api for real-time updates on game camera positions. Since the camera position data is always updating I want my wpf app to reflect those updates in realtime....would signalR be a good solution or is api polling good enough?
Or anyone has any other recommendations for a straightforward way to ensure the client recieves near real-time updates from the rest api?
Thanks!
29 Replies
SignalR would be a lot nicer than polling
oh hey pobiega! hope you doing good :D
about that btw, does signalR work with any rest api?
endpoint looks like this:
https://127.0.0.1:2999/replay/render
works to do a get request but I dont think its a websocket, if thats needed
Uh no, you need SignalR on the server AND client sides. Its a "wrapper" around websockets.
Ahh.. damn
I dont think it would work then
Whats my next best option?
in SigR, the server pushes data to the client
ah I see
if you cant modify the server, then its polling only
Alright
appreciate the help thanks
btw, I suppose multiple threads is the way to go here? if I have muliple endpoints to get data from
that seems overkill
hmm
just use async task
even if its like every 50 miliseconds update?
yes
ok im gonna give a go
periodictimer with proper use of async await and it should be fine
ok that makes me think about one thing though, why await something that I know will always update/run in the background?
wdym
if I want real time data
I sense a grave misunderstanding of how async/await and tasks work here
yea probably
i was just thinking if i wanted something that updates continiously
that i had to run it in the background or something
not really, but you could do that
this is for updating a WPF app, right?
yep
I'd probably build this with some reactive elements
so your WPF app subscribes to updates from the observable
and the "background task" polls the APIs and pushes data to the observable when available
wouldnt i get threading issues
like cross thread exception or what its called
if i use tasks
thats exactly what we are trying to avoid by using IObservable
ahhh
okay okay
ill try with it
https://www.youtube.com/watch?v=6yjl_h7-WYA is a pretty good video on how to think about reactive
awesome thanks
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.