开发者

Msgbox Wait until, VB.NET

开发者 https://www.devze.com 2023-03-08 12:06 出处:网络
Is it possible to have a Msgbox without a button on it in a console application. I would like to have a msgbox pop up and then disappear when the task has开发者_运维技巧 been completed. Or could I sen

Is it possible to have a Msgbox without a button on it in a console application. I would like to have a msgbox pop up and then disappear when the task has开发者_运维技巧 been completed. Or could I send the msgboxresult to some form of window that would just disappear when the file has been written?

MsgBox("The users on the domain are being gathered. A prompt will appear when all information has been gathered.")
    Dim userFile2 As String = savefileDialog1.FileName & ".txt"
    Dim fileExists2 As Boolean = File.Exists(userFile2)
    Using sw As New StreamWriter(File.Open(userFile2, FileMode.OpenOrCreate))
        For Each d As DirectoryEntry In de.Children()
            sw.WriteLine(d.Name)
        Next
    End Using


If you want to have a console app with a GUI, I'd suggest that it might be easier to just make a WinForms app. Just create a new tiny WinForms app, make the default Form small as a dialog box and make it have only one invisible Close button.

Then you can just show the Close button when it's finished.

Just remember to disable the Control box on the Form (the X up in the top right hand corner) and handle any keyboard combination that could close it.

Edit: Or if for any reason you have to have it as a Console app, then you could still write a tiny separate app that just does the GUI part that you need and have the Console app start up the GUI app, sending over the text to display.


First, a quick point. A MsgBox is a modal dialog so will halt execution until the user responds, you can't use this.

In general "console" applications should be non-graphical.

You don't want to use a console application to disiplay a window. Since .Net 4.0 is available to you may want a WPF application that can write to the console.

There is a post about outputting to the console with WPF here on SO.

You should do your work on a different thread perhaps using a System.ComponentModel.BackgroundWorker. This will allow the Window to respond to user interaction and render while your task progresses.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号