473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

C# GUIDsometime just went bust.

Hello,

I'm working on a GUI C# projects with a lot of threads doing many thing.
Basically the GUI is just a monitor of all the threads.

Often my application suddenly shut down without any warning. Noramlly if you
run from VS you get the Unhandled Exception dialog box, which does happen,
but occasionally it just stopped and seems like a normal termination (not).

Anyone has any suggestion about this issue?

thanks,

/m
Nov 15 '05 #1
2 1028
Are you using Control.Invoke for thread to GUI communication?

When I'm building a class and I don't know if it'll be on the same thread or
not, I use

public void CallingMethod()
{
if( control1.InvokeRequired )
{
control1.Invoke( MyMethodHandler,...)
}
else
{
control1.MyMethod();
}
}

where MyMethodHandler is a delegate that holds MyMethod();
if this class is on a different thread than the GUI, it'll call the Invoke,
if it's place on the GUI thread, it'll just call MyMethod directly.
"Muscha" <mu****@no.spam.net> wrote in message
news:OB**************@tk2msftngp13.phx.gbl...
Hello,

I'm working on a GUI C# projects with a lot of threads doing many thing.
Basically the GUI is just a monitor of all the threads.

Often my application suddenly shut down without any warning. Noramlly if you run from VS you get the Unhandled Exception dialog box, which does happen,
but occasionally it just stopped and seems like a normal termination (not).
Anyone has any suggestion about this issue?

thanks,

/m

Nov 15 '05 #2
Hi Muscha,

As Chris suggested, if you are updating your controls from
other threads (other than the GUI thread that created your control),
you will need to need to use Control.Invoke() to marshal the call
correctly to the GUI thread.

One other thing you must probably try to do is handle
exceptions in the code that raises events.

foreach(YourDelegate del in YourEvent.GetInvocationList())
{
try
{
del(some params);
}
catch(Exception ex)
{
// Maybe the event handler threw an exception.
}
}

That way, you can trap exceptions even if your event handlers such as your
GUI app
terminates unexpectedly.

Regards,
Aravind C
"Muscha" <mu****@no.spam.net> wrote in message
news:OB**************@tk2msftngp13.phx.gbl...
Hello,

I'm working on a GUI C# projects with a lot of threads doing many thing.
Basically the GUI is just a monitor of all the threads.

Often my application suddenly shut down without any warning. Noramlly if you run from VS you get the Unhandled Exception dialog box, which does happen,
but occasionally it just stopped and seems like a normal termination (not).
Anyone has any suggestion about this issue?

thanks,

/m

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

72
by: Herbert | last post by:
I'm still relativey new to stylesheets, so I'm hoping that the way I'm going about things can be seriously improved upon, i.e . I just haven't undersood something obvious about the 'cascading'...
27
by: John Bailo | last post by:
The recent quarterly earnings report, required by law, issued by the Microsoft Corporation are a harbinger of what is to come. Slowing revenue growth, and declining profits. What we see here is...
99
by: Jim Hubbard | last post by:
It seems that Microsoft not only does not need the classic Visual Basic developer army (the largest army of developers the world has ever seen), but now they don't need ANY Windows developer at a...
11
by: Liz | last post by:
anyone have any idea why there have been (at least) 82 VS 2008 post-release messages here on the C# board but only 5 on the VB.NET board; are the VB crowd just not interested?? strikes me as a...
7
by: noob | last post by:
Hi all, I want to display advertising in iframe, but bust out of iframe if someone clicks on any of the links in there. Can u please help. I googled for it, but I am not sure about the...
1
by: VK | last post by:
On Jun 8, 12:07 am, Dr J R Stockton <j...@merlyn.demon.co.ukwrote: That would be clearly a childish behavior: "it is OK to do if daddy cannot see it". W3C Validator doesn't really validate...
2
by: Conrad Lender | last post by:
On 2008-09-23 20:57, jhaight@gmail.com wrote: I think I know what the problem is. Hope that helped. - Conrad PS: Are the posts getting more and more bizarre in this group?
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
Can someone confirm if my no spam alias is set up correctly to get answers to questions. I have been talking to the concierge for over a week to get an answer to a question. Each time I am told to...
0
Chuncatty
by: Chuncatty | last post by:
How much does a Draped Bust coin fabricate cost? (Sorry for my Eng) I ask a beau to see if it's genuine he said it is, down repay a collage professor i met said so. It's in virtue word,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.