Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 显示消息框后如何停止功能_C#_Wpf_Function_C# 4.0_C# 3.0 - Fatal编程技术网

C# 显示消息框后如何停止功能

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();

我正在从CreateFileOutput()调用TransactionFileCreation()。一旦显示消息框,该功能将不起作用。但在我的例子中,它再次转到main函数并显示其中的msg框。显示消息框后如何停止执行。给我一个解决方案。谢谢。

您可以使用
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.");
}

是否要关闭应用程序?是否要关闭应用程序?