C# 显示消息框后如何停止功能
我正在从CreateFileOutput()调用TransactionFileCreation()。一旦显示消息框,该功能将不起作用。但在我的例子中,它再次转到main函数并显示其中的msg框。显示消息框后如何停止执行。给我一个解决方案。谢谢。您可以使用C# 显示消息框后如何停止功能,c#,wpf,function,c#-4.0,c#-3.0,C#,Wpf,Function,C# 4.0,C# 3.0,我正在从CreateFileOutput()调用TransactionFileCreation()。一旦显示消息框,该功能将不起作用。但在我的例子中,它再次转到main函数并显示其中的msg框。显示消息框后如何停止执行。给我一个解决方案。谢谢。您可以使用Application.Current.Shutdown()从任意点退出应用程序 public void CreateFileOutput(object parameter) { TransactFileCreation();
Application.Current.Shutdown()
从任意点退出应用程序
public void CreateFileOutput(object parameter)
{
TransactFileCreation();
WPFMessageBox.Show("test", "Process completed successfully.");
}
public void TransactFileCreation()
{
if (BatchFolderPath == null)
{
WPFMessageBox.Show("test", "Select a Batch folder");
return;
}
// code..
}
您可以使用
Application.Current.Shutdown()
从任意点退出应用程序
public void CreateFileOutput(object parameter)
{
TransactFileCreation();
WPFMessageBox.Show("test", "Process completed successfully.");
}
public void TransactFileCreation()
{
if (BatchFolderPath == null)
{
WPFMessageBox.Show("test", "Select a Batch folder");
return;
}
// code..
}
通常,您会从
transactinfilecreation
返回一个bool
,告知操作是否成功
或者,在严重的情况下,您会抛出异常,但这仅适用于非常规错误流。通常,您会从
TransactionFileCreation
返回一个bool
,告知操作是否成功
或者在严重情况下抛出异常,但这仅适用于非常规错误流。您可以返回布尔值:
public void TransactFileCreation()
{
if (BatchFolderPath == null)
{
WPFMessageBox.Show("test", "Select a Batch folder");
Application.Current.Shutdown();
}
// code..
}
然后你这样叫:
public bool TransactFileCreation()
{
if (BatchFolderPath == null)
{
WPFMessageBox.Show("test", "Select a Batch folder");
return false;
}
// code..
return true;
}
您可以返回一个布尔值:
public void TransactFileCreation()
{
if (BatchFolderPath == null)
{
WPFMessageBox.Show("test", "Select a Batch folder");
Application.Current.Shutdown();
}
// code..
}
然后你这样叫:
public bool TransactFileCreation()
{
if (BatchFolderPath == null)
{
WPFMessageBox.Show("test", "Select a Batch folder");
return false;
}
// code..
return true;
}
创建Transact-FileCreation()以返回bool
public void CreateFileOutput(object parameter)
{
if (!TransactFileCreation())
return;
WPFMessageBox.Show("test", "Process completed successfully.");
}
创建Transact-FileCreation()以返回bool
public void CreateFileOutput(object parameter)
{
if (!TransactFileCreation())
return;
WPFMessageBox.Show("test", "Process completed successfully.");
}
是否要关闭应用程序?是否要关闭应用程序?