[WP7][MVVM Light toolkit] Button Command raised too early, before binding when using mvvm-light toolkit
By : user2398912
Date : March 29 2020, 07:55 AM
|
Async communication between ViewModel and Model using MVVM-Light messaging?
By : user2640905
Date : March 29 2020, 07:55 AM
I wish this helpful for you Are you sure you're making the request in the right place? Typically the Model contains simply the data that you want to store/transfer and the View Model would handle transforming that Model's properties so that a View can display (or edit) that Model. I would imagine that Model objects are what you're going to get back from the HttpWebRequest, and so you may want to consider using a Service class to handle retrieving the data, though that may be overkill for your application. Either way, I'd highly reccomend that you handle the request and the parsing of the response in the same place; otherwise you are spreading the logic across multiple places, which is just going to get confusing and hard to maintain.
|
Why does async method block MVVM Light Relay Command
By : Wim Tuijl
Date : March 29 2020, 07:55 AM
this will help The await itself will not block your UI. It is more likely that your Upload() method does not do any real asynchronous work. (As Jim suggested, Task.Run() can be used in such a case. It will use the thread pool to run the operation in the background. Generally speaking, for IO-bound operations like uploads/downloads you should check if your API supports asynchronous calls natively. If such an implementation exists, it may make more efficient use of system resources than using a thread.)
|
mvvm light async call in viewmodel constructor
By : user77123
Date : March 29 2020, 07:55 AM
|
MVVM Light Call async method on property changed?
By : faten emad
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further The issue is here not how to run an async task unobserved, its what do you do with the exceptions. I say this because they might turn up when the task gets cleaned up. Ideally, just show the next reader what they are getting. Since you are against the use of async void code :
// running an async method unobserved
Task.Run(async () =>
{
try
{
await DoSomethingAsync();
}
catch (Exception e)
{
// Deal with unobserved exceptions
// or there will be dragons
}
});
public async void DoSomethingFireAndForget()
{
try
{
await DoSomethingAsync();
}
catch (Exception e)
{
// Deal with unobserved exceptions
// or the will be dragons
}
}
public static class TaskUtils
{
#pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void
public static async void FireAndForgetSafeAsync(this Task task, Action<Exception> onErrors = null)
#pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void
{
try
{
await task;
}
catch (Exception ex)
{
onErrors?.Invoke(ex);
}
}
}
|