I have a main form (frmMain).
frmMain creates a sub form (frmSub).
frmSub creates a business object (busObj).
busObj creates a thread and calls a method to run in the thread.
The method creates a server side buiness object (busObjSrv).
busObjSrv creates an Excel.Applicati on (exAp) object on the server.
exAp opens an automated excel woekbook (exWb) (automated by an outside
company)
busObjSrv fills the information from frmSub on exWb and calls the automation
methods.
The automation methods generate 2 word documents based on the information
from frmSub, and data from the other company located on the work book.
Sorry for the long explenation, but heres the problem...
once busObj spins the thread off, frmSub closes and breaks the object link
between busObj and frmMain. If an exception is thrown in busObjSrv, I cannot
pass it back to frmMain to display to the user through the catch blocks. A
general exception gets thrown (break/continue) and the program does not blow
up, but the exception is not being handled properly (IMO).
Does anyone know a way that I can pass the exception back to frmMain to
display in a MessageBox?
We have several business objects that use threading, and I would like to
incorporate a solution into a utility object that we can use for all
threading.
If I figure it out first... I will post the solution in case someone else
needs it.
Thanks in advance.
bobc 5 1569
How about an event that is fired when a exception gets thrown. You can
then have an exception handler that subscribes to the events and
displays something in the UI when the event gets fired.
If the sub form creates the business object and then goes away, how does the
main form know that the business object even exists?
bobc
"Bob Calvanese" <bc********@com cast.net> wrote in message
news:z4******** ************@co mcast.com... I have a main form (frmMain). frmMain creates a sub form (frmSub). frmSub creates a business object (busObj). busObj creates a thread and calls a method to run in the thread. The method creates a server side buiness object (busObjSrv). busObjSrv creates an Excel.Applicati on (exAp) object on the server. exAp opens an automated excel woekbook (exWb) (automated by an outside company) busObjSrv fills the information from frmSub on exWb and calls the automation methods. The automation methods generate 2 word documents based on the information from frmSub, and data from the other company located on the work book.
Sorry for the long explenation, but heres the problem...
once busObj spins the thread off, frmSub closes and breaks the object link between busObj and frmMain. If an exception is thrown in busObjSrv, I cannot pass it back to frmMain to display to the user through the catch blocks. A general exception gets thrown (break/continue) and the program does not blow up, but the exception is not being handled properly (IMO).
Does anyone know a way that I can pass the exception back to frmMain to display in a MessageBox?
We have several business objects that use threading, and I would like to incorporate a solution into a utility object that we can use for all threading.
If I figure it out first... I will post the solution in case someone else needs it.
Thanks in advance.
bobc
Well, you have to make the MainForm subscribe to events fired from the
business object.
Regards
Senthil
So even though the main form creates the sub form, and the sub form creates
the business object, and the sub form closes... That the main form knows
that there is a business object?
I thought that the business object would only be known by the object that
created it. Could you explain how that is form me so I can understand?
I'll give it a try... Thanks
bobc
"sadhu" <se**********@w devs.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. . Well, you have to make the MainForm subscribe to events fired from the business object.
Regards Senthil
Something like this
public class MainForm : Form
{
public void CreateSubForm()
{
SubForm s = new SubForm(this);
s.Show();
}
internal void ExceptionHandle r(Exception e)
{
MessageBox.Show (e.ToString());
}
}
class SubForm : Form
{
MainForm f;
public SubForm(MainFor m f)
{
this.f = f;
}
void CreateBusinessO bject()
{
BusinessObject bo = new BusinessObject( );
bo.ExceptionOcc urred += new
ExceptionOccurr edEventHandler( f.ExceptionHand ler);
}
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steven Bethard |
last post by:
I feel like this has probably been answered before, but I couldn't
find something quite like it in the archives. Feel free to point me
somewhere if you know where this has already been answered.
I have a list in a particular order that I want to split into two
lists: the list of every nth item, and the list of remaining items.
It's important to maintain the original order in both lists.
So the first list is simple:
|
by: OvErboRed |
last post by:
I just read a whole bunch of threads on microsoft.public.dotnet.* regarding
checked exceptions (the longest-running of which seems to be <cJQQ9.4419
$j94.834878@news02.tsnz.net>.
My personal belief is that checked exceptions should be required in .NET. I
find that many others share the same views as I do. It is extremely
frustrating to have to work around this with hacks like Abstract ADO.NET
and CLRxLint (which still don't solve the...
|
by: Shane Groff |
last post by:
I know this is a recurring discussion (I've spent the last 3 days
reading through threads on the topic), but I feel compelled to start
it up again.
After reading through the existing threads, I find myself convinced
that exceptions are a better mechanism, for example because
constructors and operators can't return errors, and code that doesn't
need to handle/translate/recover in the face of errors, but can just
propagate the error is...
|
by: RepStat |
last post by:
I've read that it is best not to use exceptions willy-nilly for stupid purposes as they can be a major performance hit if they are thrown. But is it a performance hit to use a try..catch..finally block, just in case there might be an exception? i.e. is it ok performance-wise to pepper pieces of code with try..catch..finally blocks that must be robust, in order that cleanup can be done correctly should there be an exception?
|
by: Miyra |
last post by:
Hi. I'm working with an app that uses exceptions for control flow.
These are code blocks where exceptions are thrown/caught regularly. A
couple hundred exceptions occur per hour and they're caught close to
the point of origination. I'm trying to decide whether to refactor...
What is the cost of throwing an exception in the CLR - relative to,
say, a conditional statement? Are we taking talking 1+ orders of
magnitude? Is there...
| |
by: Einar Høst |
last post by:
Hi,
I'm getting into the Trace-functionality in .NET, using it to provide some
much-needed logging across dlls in the project we're working on. However,
being a newbie, I'm wondering if some more experienced loggers can provide
me with some ideas as to how to log in a simple yet flexible manner. For
instance, I'd like the code to be as uncluttered as possible by Trace
statements.
As an example of basic logging functionality, I've come...
|
by: Cool Guy |
last post by:
Consider:
void Start()
{
if (!TryToDoSomething())
ShowErrorMessage();
}
|
by: robert |
last post by:
I get python crashes and (in better cases) strange Python exceptions when (in most cases) importing and using cookielib lazy on demand in a thread.
It is mainly with cookielib, but remember the problem also with other imports (e.g. urllib2 etc.).
And again very often in all these cases where I get weired Python exceptions, the problem is around re-functions - usually during re.compile calls during import (see some of the exceptions below). But...
|
by: Denis Kukharev |
last post by:
I have a problem when catching a plenty of exceptions simultaneously in different threads: the Load Average indicator exceeds 100.0 and the process seems to "hang up".
I managed to simulate this situation having created a test program with a number of threads about 200 each containing a FINITE loop with throwing and catching an exception. The exceptions don't leave thread function. The test starts to work and at some moment blocks. Under some...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |