Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / September 2007

Tip: Looking for answers? Try searching our database.

I may be outside the UI thread

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Thielen - 05 Sep 2007 17:14 GMT
Hi;

I am getting an exception calling ShowWindow() sometimes and I am wondoering
if I am outside the UI thread in that case. Here is what I am doing:

Create a dialog with:
using (SpawnReport dlg = new SpawnReport(app, ext))
{
    dlg.ShowDialog();
}

In the constructor for this dialog (Form actually) I have:
    this.Activated += new System.EventHandler(this.Report_Activated);

I assume that Report_Activated is called in the UI thread - is this correct?

Inside Report_Activated I call:
    BeginInvoke(new LaunchDelegate(LaunchReport));

I assume LaunchReport is called in the context of the UI thread. Is this
correct?
And LaunchReport calls Close() as it's last line of code - is this ok?
And in LaunchReport it calls Update(); Application.DoEvents(); when it is
updating the status Label in the Form - is this ok?

This all seems right to me but I may be missing a possible thread context
switch.

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

Linda Liu [MSFT] - 06 Sep 2007 11:43 GMT
Hi Dave,

> I am getting an exception calling ShowWindow() sometimes
What's the exception do you get?

> I assume that Report_Activated is called in the UI thread - is this correct?
Yes, the Report_Activated handler is called in the UI thread.

> I assume LaunchReport is called in the context of the UI thread. Is this
correct?
Yes.

> And LaunchReport calls Close() as it's last line of code - is this ok?
What the object do you call the Close method on?

> And in LaunchReport it calls Update(); Application.DoEvents(); when it is
updating the status Label in the Form - is this ok?
Yes, it should be ok.

If possible, could you please send me a simple project that could just
reproduce the problem? To get my actual email address, remove 'online' from
my displayed email address.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
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.
David Thielen - 06 Sep 2007 17:58 GMT
Hi;

The problem is we do not get the bug here. We have 1 user getting it and she
gets it intermittently. Mostly she gets a message "Word experienced a serious
problem with the 'windward autotag 2007' add-in...

Or it throws an exception "External component has thrown an exception."
inside a method like (the method throwing it changes)
System.Drawing.SafeNativeMethods.Gdip.GdipMeasureString.

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

> Hi Dave,
>
[quoted text clipped - 43 lines]
>  
> This posting is provided "AS IS" with no warranties, and confers no rights.
Walter Wang [MSFT] - 10 Sep 2007 13:26 GMT
Hi Dave,

I hope you could understand that for such intermit error, there's really
not much we can do from newsgroup. You may contact Microsoft Customer
Support and Service for further help. Thanks for your understanding.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
David Thielen - 10 Sep 2007 18:30 GMT
I was afraid of that. I wrote in case I made a bad assumption about always
being in the UI thread in each of the event handlers.

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

> Hi Dave,
>
[quoted text clipped - 12 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
Ben Voigt [C++ MVP] - 11 Sep 2007 01:57 GMT
>I was afraid of that. I wrote in case I made a bad assumption about always
> being in the UI thread in each of the event handlers.

Best thing to do is install a global exception handler that writes the
exception details to a log file (along with thread id).

>> Hi Dave,
>>
[quoted text clipped - 13 lines]
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
David Thielen - 11 Sep 2007 04:02 GMT
Hi;

I can't - this is for a Word AddIn so it owns the app - we're just a dll it
calls.

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

> >I was afraid of that. I wrote in case I made a bad assumption about always
> > being in the UI thread in each of the event handlers.
[quoted text clipped - 19 lines]
> >> This posting is provided "AS IS" with no warranties, and confers no
> >> rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.