Skip to content

Properly using HandleTask #751

@codinghavok

Description

@codinghavok

Hello, I'm upgrading from 3.2 to 4.0. I like to display progress messages in my applications ShellViewModel when changing to my apps "profile screen". Since 4.0 is a little different now being async, do I still need to keep the body of my HandleTasks the same if I'm only upgrading to the new signature and want to keep functionality the same? I have included my loading message method below.

If this is incorrect use , can you please provide an example of how it should be done. Thanks.

public async System.Threading.Tasks.Task HandleAsync(LoadProfileMessage message, System.Threading.CancellationToken cancellationToken)
        {           
            await System.Threading.Tasks.Task.Run(() =>
            {
                BusyMessage = "Loading Profile...";

                IsBusy = true;

                var viewModel = Items.OfType<ProfileViewModel>().FirstOrDefault();

                viewModel.Init(message.ProfileId);

                ProfileViewModel = viewModel;

                ActivateItemAsync(viewModel);

                IsBusy = false;                
            });
            await System.Threading.Tasks.Task.CompletedTask;
        }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions