I have a camera function that is giving me a hard time.
When the user selects the option to add a photo to the record in the app, the code launches a popup, to ask options for the image, but the thread continues on since the PopupView
is non Awaitable
.
There are only two ways I can think to handle this,
CarouselView
or just signal to refresh display by rerunning the Repository<T>().GetItems()
call. The main problem with this I can see, is that since the callback would be called from a different thread, I wouldn't necessarily have access to the instance of the database object on the display. (I could try some ExecuteOnMainThread
type thing, but I don't know how well that would work.DoWhile
thread that refreshes the database objects on the screen, blocked on a GlobalClass.Semaphore
and then signal that same Global.Semaphore
from the camera function.I don't know, perhaps that is the best method to use for this? I always figured C# is just a easier to use more automated C++. I just don't know enough about standards of C# threading vs C/C++. In some ways I miss the old Main
thread loop, other times, I am glad to not have to deal with it....
Any advice greatly appreciated!
Cheers!
Answers
Extension of this question.
I am using an
AsyncronousInitializer
interface I created for myViewModels
. All of myViewModel
classes are inherited from aBaseViewModel
class. I have decided to move theIAsyncInitializer
interface to theBaseViewModel
. By doing this, I can basically create a simple function in the base class.In the function I need to use this, I can then call it like this
Then in my GetPhoto class
The problem is, How should I create the interface in the
BaseViewModel
?or
Implicit, vs Local.
I need to overload the Initialization() function in each of the child classes, so I am not sure which method would work better?
Sorry, I think I've figured out part of my problem with the
BaseViewModel
idea.I cannot overload the base implementations of the interface. I will have to implement the interface and the function in each of the
ViewModels
that need it.You can use
MediaPlugin
and MVVM to achieve it, this plugin could have async/await method, If you do not need it, please share a demo or related code that could reproduce this issue.@LeonLu Hello, I'm sorry this is more or less a duplicate thread to the other one we are talking on. Same issue, I accidentally created the other thread as a mistake.
The issue is the same in both. The other thread has more code and in depth descriptions, so I would continue the discussion there if you like.
Thanks again!