you are queuing up control update requests on the UI thread. this is probably tying up the UI thread.
maui user interface responsivity issue
Hi all
I rewritten a winforms app to maui app
this app run a long processing method
In winforms the UI is responsive but
in maui isn't.
note this method while processing is writing
results text to a textbox in winforms
and to an editor in maui.
Note if uncommenting this statement
//if(results == 1) ==> If huge results processing for cancel test // I added this for testing only
then when there a huge processing the cancel is succeeded but if commented
cancel do not succeed.
Note that in small processing cancel always succeed when this statement commented
public Task longthy_method(CancellationToken ct)
{
return Task.Run(() =>
{
try
{
. . . . .
progressBar.Progress = 0;
for(int combs = 0; combs < Total; combs++)
{
while (iPN < PN)
{
. . . .
while(iPY < PY)
{
if (ct.IsCancellationRequested)
{
stopwatch.Stop();
strOutputTBText += "Time elapsed:\r\n" + stopwatch.Elapsed;
strOutputTBText += "\r\n";
MainThread.BeginInvokeOnMainThread(() => {OutputTB.Text += strOutputTBText;});
throw new OperationCanceledException(ct);
}
. . . . .
//if(results == 1) ==> If huge results processing for cancel test
MainThread.BeginInvokeOnMainThread(() => {OutputTB.Text += thisSolution + "\r\n";});
}
}
}
}//*** while(iPY < PY)
}//*** while (iPN < PN)
}//for(combs
}
catch (Exception ex)
{
if(ex.ToString().Contains("OperationCanceledException"))
{
//
}
else
{
strOutputTBText = "\r\n\r\n";
strOutputTBText += $"Exception = " + ex + "\r\n";
strOutputTBText += $"Invalid Output";
strOutputTBText += "\r\n\r\n";
//if(results == 1) ==> //If huge results processing for cancel test I added this for testing only
MainThread.BeginInvokeOnMainThread(() => {OutputTB.Text += strOutputTBText;});
}
}
finally
{
progressBar.Progress = 0.0;
}
}, ct);
}//longthy_method
can someone help in this
thank you very much