Closed jom16antonio closed 5 years ago
Yes. I finished the bindings and am working on nuget package. I hope it will be released soon.
WorkManager is still in preview from Google. We are working on bindings for it in the meantime.
Theres a rc01 (release candidate) hope we could test your bindings with that version.
Any update on WorkManager support, now that Google have pushed a stable release, identical to the release candidate, on the 5th of March?
https://www.nuget.org/packages/Xamarin.Android.Arch.Work.Runtime
Just published, should work for you now :)
I added that NuGet package to my project, but I don't appear to have any access to the Xamarin.Android.Arch namespace?
Edit: Fixed. It helps if you target v28 SDK, heh :)
@sdobart How did you do? I cannot find the Worker
class, can you help please?
@elisabeth-mitton You need to change your Android project's target SDK to version 28 (9.0 Pie), and then install the NuGet Package "Xamarin.Android.Arch.Work.Runtime".
I am targeting SDK 28 and have the nuget installed yet getting the type or namespace AndroidX could not be found.
Any help please? @moljac
Can anyone comment if the Xamarin WorkManager bindings support "ListenableWorker"?
I know it supports "Worker", but that requires that all of the work be done synchronously. In order to do any asynchronous work the worker needs to sub-class "ListenableWorker" directly.
The "ListenableWorker" is supposed to have an abstract "startWork()" function, but I'm not seeing it in the class definition from the "Xamarin.Android.Arch.Work.Runtime" NuGet package. https://developer.android.com/reference/androidx/work/ListenableWorker.html#startWork()
Can anyone comment if the Xamarin WorkManager bindings support "ListenableWorker"?
I know it supports "Worker", but that requires that all of the work be done synchronously. In order to do any asynchronous work the worker needs to sub-class "ListenableWorker" directly.
The "ListenableWorker" is supposed to have an abstract "startWork()" function, but I'm not seeing it in the class definition from the "Xamarin.Android.Arch.Work.Runtime" NuGet package. https://developer.android.com/reference/androidx/work/ListenableWorker.html#startWork()
I was under the impression that Xamarin WorkManager's "Worker" was asynchronous. https://devblogs.microsoft.com/xamarin/getting-started-workmanager/
@SteveFarmerJr The doWork() entry point is called from a background thread, but the execution itself is synchronous - there's no way to eg. start some asynchronous operation, giving the doWork() thread back to the pool and then resume on a different background thread when the operation is complete.
It's not a show stopper, you can call .Wait() which blocks the doWork() thread, it just makes it more difficult to work with existing async/await or IObservable C# code.
While I have not tested that it actually works, I can confirm the bindings do exist for ListenableWorker, and I am able to inherit from it.
@sdobart: Indeed, we can create a worker that will inherit from ListenableWorker, but @jalbertSyncroTech is correct, the startMethod is currently not available.
@moljac: Could you implement it? :)
@toussam Open a new issue please!
Could you implement it?
Maybe implememntation is not necessary. Maybe the method was not surfaced for some reason.
And mention me. I did part of the bindings.
Done! Thank you for your quick reply @moljac. ~
Wishing you a great weekend!
I found this thread on Google, trying to figure out what the namespace was for the "Worker" class because the docs (https://devblogs.microsoft.com/xamarin/getting-started-workmanager/) make no mention of it. Turns out the namespace we're looking for is AndroidX.Work, in case anybody else came here looking for the same thing.
How is anybody supposed to know this if the documentation omits it? A simple "using" statement at the top of your code examples would really go a long way in these cases.
This is just a quick inquiry. How do I use WorkManager with Xamarin? Is this something being worked on?