A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
you are queuing up control update requests on the UI thread. this is probably tying up the UI thread.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
Answer accepted by question author
you are queuing up control update requests on the UI thread. this is probably tying up the UI thread.