Reputation: 3823
now program show Messagebox and wait user decision. How make, that program don't wait? Show Messagebox, ant keep going. (I do not need a user action. I just need to show text)
Or maybe a better option than to report the information to a new window?
I hope to understand my problem.
Upvotes: 1
Views: 296
Reputation: 9986
If you just have to show a notification window, then this would be a help that I wrote sometime back; works like Outlook like notification window.
Upvotes: 0
Reputation: 2860
quick and easy way: use a BackgroundWorker
to host your long running job and use the worker's events to pop up messages in the UI thread.
edit: might want to display the messages in the form of a message log.
public partial class MainWindow : Form
{
#region Constructor
public MainWindow()
{
InitializeComponent();
}
#endregion
#region Events
private void button_Click(object sender, EventArgs e)
{
listBox.Items.Add("Job started!");
backgroundWorker.RunWorkerAsync();
}
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 0; i < 10; i++)
{
// send data from the background thread
backgroundWorker.ReportProgress(0, i);
}
}
private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
// communicate with UI thread
listBox.Items.Add(string.Format("Received message: {0}", e.UserState));
}
private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
listBox.Items.Add("Job done!");
}
#endregion
}
Upvotes: 1
Reputation: 1039298
Create a new Form, put some controls on it and show it to the user:
new PopupForm().Show();
Upvotes: 1