MahApps.Metro icon indicating copy to clipboard operation
MahApps.Metro copied to clipboard

Progress ring not activating before slow function call

Open akshithrajesh290 opened this issue 10 years ago • 4 comments

@crclayton You can do something like this:

private void DoSomething_Click(object sender, RoutedEventArgs e)
{
//Make Progress Ring Visible/active
Wait.IsActive = true;

  BackgroundWorker worker = new BackgroundWorker();
  worker.DoWork += worker_DoWork;
  worker.RunWorkerCompleted += new         RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
  worker.RunWorkerAsync();
}

void worker_DoWork(object sender, DoWorkEventArgs e)
{
doSomething();
}

protected void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//Make Progress Ring inActive/hidden
Wait.IsActive = false;
}

Hi I followed the same process ! I got 1 Issue Stating that "the-calling-thread-cannot-access-this-object-because-a-different-thread-owns-it"

So I placed the Below Code

this.Dispatcher.Invoke((Action)(() =>
{
...// your code here.
}));

I set the Property of the Progress ring to visibility to Visibility.True

It was not showing the Progress Ring (It was not Activating ).

Again By default I set the property of Progress Ring to Visibility.True on Page Load itself

This Time doWorkerAsync() Method closes the Progress Ring

akshithrajesh290 avatar May 19 '16 09:05 akshithrajesh290

I can't reproduce it. What is your actual code?

Dotnetifier avatar May 23 '16 10:05 Dotnetifier

Hi

I tried to show the Progress ring when my Background work continues. And I need to show it when my process start and need to close when my process end

I tried to achieve it by calling the method asynchronously by using the BackgroundWorker process

But Here when I call the method asynchronously (I had activated the progress ring (or) set the visibility property of the progress ring to True

(Main Issue is I am unable to show the Progress ring when My Background work is running)

akshithrajesh290 avatar May 23 '16 11:05 akshithrajesh290

In DoSomething_Click you shoud set IsActive = true; and in worker_RunWorkerCompleted you should set IsActive = false; and everything works. You should not set IsActive in worker_DoWork because that method must only do work.

Dotnetifier avatar May 23 '16 12:05 Dotnetifier

@akshithrajesh290 Is this still a problem for you? It seems that this is not MahApps related...

punker76 avatar Jun 07 '16 21:06 punker76