Simple problem with a SaveFileDialog

  • Thread starter Thread starter Oriane
  • Start date Start date
O

Oriane

Hi there,

I use this very simple code:
__________________________________________________________________________
private void OnExport (object sender, EventArgs e) {
// SaveFileDialog saveFileDialog1 is a member
DialogResult result = saveFileDialog1.ShowDialog ();
if ( result == DialogResult.OK)
{
XmlTextWriter xtw = new
XmlTextWriter(saveFileDialog1.FileName, Encoding.UTF8);
xtw.WriteStartDocument(true);
xtw.WriteStartElement("File");
string role;
// ProgressBar progressBar1 is a member
progressBar1.Show();
progressBar1.Focus();
....}

and my problem is that when the treatment with the XmlTextWriter begins and
that the progress bar appears, my SaveFileDialog is not closed, but still
appears on my app.

I can't figure out why.

Best regards
 
Oriane said:
Hi there,

I use this very simple code:
__________________________________________________________________________
private void OnExport (object sender, EventArgs e) {
// SaveFileDialog saveFileDialog1 is a member
DialogResult result = saveFileDialog1.ShowDialog ();
if ( result == DialogResult.OK)
{
XmlTextWriter xtw = new
XmlTextWriter(saveFileDialog1.FileName, Encoding.UTF8);
xtw.WriteStartDocument(true);
xtw.WriteStartElement("File");
string role;
// ProgressBar progressBar1 is a member
progressBar1.Show();
progressBar1.Focus();
...}

and my problem is that when the treatment with the XmlTextWriter
begins and that the progress bar appears, my SaveFileDialog is not
closed, but still appears on my app.

I can't figure out why.

Best regards

Consider putting the export into another thread, so your UI thread will be
able to update the screen.


Armin
 
Hi Oriane,

I performed a test based on your sample code but didn't reproduce the
problem on my side.

When we call SaveFileDialog.ShowDialog method, the SaveFileDialog is shown
modally and this method doesn't return until the SaveFileDialog is closed.
That's to say, it's AFTER the SaveFileDialog is closed that the
XmlTextWriter begins to write text into the specified file.

Even though the XmlTextWriter will take a long time to write text into the
file, it won't block the SaveFileDialog.

Since I couldn't reproduce the problem on my side, could you please send me
a simple project that could reproduce the problem? My email address is
(e-mail address removed).

I look forward to your reply!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Linda,
Linda Liu said:
Hi Oriane,

I performed a test based on your sample code but didn't reproduce the
problem on my side.

When we call SaveFileDialog.ShowDialog method, the SaveFileDialog is shown
modally and this method doesn't return until the SaveFileDialog is closed.
That's to say, it's AFTER the SaveFileDialog is closed that the
XmlTextWriter begins to write text into the specified file.
Yes this is the way it should work...
Even though the XmlTextWriter will take a long time to write text into the
file, it won't block the SaveFileDialog.

Since I couldn't reproduce the problem on my side, could you please send
me
a simple project that could reproduce the problem? My email address is
(e-mail address removed).
Since this is a minor problem, and since I would have to modify my code to
send it to you, I thank you but there is no need to continue this topic.
Alternatively, I can follow Armin suggestion and use a background worker
thread.

Best regards
 
Hi Armin,
Armin Zingler said:
Consider putting the export into another thread, so your UI thread will be
able to update the screen. Yes I will try...

Armin
Thanks a lot
 
Hi Oriane,

Thank you for your response!

Well, I will close this issue. If you need our further assistance, please
feel free to re-open this issue and I will continue to work with you.

Have a nice day.

Sincerely,
Linda Liu
Microsoft Online Community Support
 
Back
Top