Most tools are executed asynchronously, so the prompt information needs to be executed asynchronously before proceeding, so pay attention to the use of async and await.
For articles related to async and await, please check out C# to thoroughly understand async/await_c# async await-CSDN blog
public async Task InformationPrompt()
{
string message = String.Empty;
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
try
{
if(true){message = "true";}
else{message = "false";}
}
catch (GeodatabaseException exObj)
{
message = exObj.Message;
}
}
});
if (!string.IsNullOrEmpty(message))
MessageBox.Show(message);
}