|
|
If the worker thread is a threadpool thread created using BeginInvoke, then the CLR catches and rethrows the exception when you call EndInvoke (usually called in the callback).
Hope this helps.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I would think the CLR would have to or thread pooling wouldn't be a viable feature.
Still though, I don't control the creation of the thread that would be firing the exception. I think I'll have to settle for an manual notification (event perhaps), which won't be the same as an actual exception, but I can always throw one as a result of the notification.
Thanks to all for the responses.
NIK
|
|
|
|
|
I did a search with what's in the subject line and got no results. How can I transfer data from one form to another? There is an example in the VS Help section that instructs you to create a class to hold the data. Is there an easier and faster way?
Thanx
Jude
|
|
|
|
|
How are the forms related?
|
|
|
|
|
Parent form calls a simple form with a textbox and 2 buttons.
Jude
|
|
|
|
|
TheJudeDude wrote: There is an example in the VS Help section that instructs you to create a class to hold the data
Sounds reasonable if it is for more than the odd string or int .
TheJudeDude wrote: Is there an easier and faster way?
Define easy and fast. e.g. Easy to impliment doesn't generally equate to easy to maintain.
You might get some ideas here: Passing values between forms[^]
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
If you want to do it with the "right" way, see this example:
public class DataClass
{
private string myData = "";
public string MyData
{
get { return this.myData; }
set { this.myData = value; }
}
}
public class FormA : Form
{
private DataClass dataClass = null;
public FormA(DataClass dataClass)
{
this.dataClass = dataClass;
}
}
public class FormB : Form
{
private DataClass dataClass = null;
public FormB(DataClass dataClass)
{
this.dataClass = dataClass;
}
}
public class Main
{
private DataClass dataClass = new DataClass();
private FormA forma = null;
private FormB formb = null;
public Main()
{
this.dataClass.MyData = "Hello World";
this.forma = new FormA(this.dataClass);
this.formb = new FormB(this.dataClass);
}
}
|
|
|
|
|
I have 2 string, but i need 1 column in TreeList.
I have string_1 show in TreeList and string_2 is data from string_1.
How to add in TreeList?
-- modified at 17:09 Thursday 18th May, 2006
|
|
|
|
|
I want to make setup project for my C# windows application,that i in visual studio 2005 develop.I want embed the dotnetframewok 2.0 in my setup project.during installation first will it search dotnetframework on the pc.if it not installed,will it install first dotnetframework and after this will continue to install my application.there is a tool that name bootstrapper is in visual studio 2003 but there isn't in visual studio 2005.How can ı do this please help...
|
|
|
|
|
please help i must make setup project for tomorrow...
|
|
|
|
|
Download it form Microsoft[^].
------------------------------ "The Soapbox has been so ..."
|
|
|
|
|
first page that you url give is about visual studio 2005 but bootstrapper is for visual studio 2003...
|
|
|
|
|
Ok, this seems like it should be simple to do but it is giving me a headache.
Lets say a function returns an object but I dont know what the type of the object is, such as:
object SomeFunction ()<br />
{<br />
return object;<br />
}
And I would like to create a new variable based on the type of object returned.
object o = SomeFunction();<br />
System.Type t = o.GetType();<br />
t NewVar = null;
Why cant I use t to declare the type for NewVar? There has to be a simple way to do this.
|
|
|
|
|
Why should it work? t is a variable, no metter if it's a System.Type, it's still a variable...
I can advise you to do something:
1. either you do a case\if statements to get the Type and do by that.
2. OR either you can do an interface (or use one) that all the types you need can implement from it, eg. string\int.... are most likly implementin ICompareable, you can use that.
I have no more ideas for that...
|
|
|
|
|
Ok, yes t is a variable - but it is holding the magic word the program needs to create the new variable.
Is there any way to extract the type from t so the program thinks it is declaring a variable of that type?
|
|
|
|
|
object newObj = o.GetType().GetConstructor(new Type[] { }).Invoke(new object[] { });
That's assuming there's a default public constructor (one that doesn't have any parameters).
|
|
|
|
|
If you want to create a new instance of a particular type, take a look at Activator.CreateInstance . Notice that it will give you an Object or ObjectHandle back, depending on which overload you call. If you are programming to a interface or there is a base class to the type you are creatting at runtime, you can cast the returning object instance to that type (interface or base class), otherwise you will need your function to return type Object.
This changes with generics in .NET 2.0 however, you can declare a generic method similar to what you had define above, though the syntax looks more like this:
public class Builder
{
public static T Create<T>() where T : class
{
T var = Activator.CreateInstance<T>();
return var;
}
}
Then I can just specify the type as such (assuming a Car and Truck class exist somewhere):
Car c = Builder.Create<Car>();
Person p = Builder.Create<Truck>();
|
|
|
|
|
I have a group of icons in an imagelist. When I try...
item.Icon = (Icon) iconList.Images[def.ImageIndexValue];
...I'm told that I cannot convert an image to an icon. Is this even possible?
|
|
|
|
|
This is a bit awkward but try it anyway:
<br />
Image img = iconList.Images[def.ImageIndexValue];<br />
Bitmap bitmap = new Bitmap(img);<br />
Graphics.FromImage(bitmap).DrawImageUnscaled(img, 0, 0);<br />
item.Icon = Icon.FromHandle(bitmap.GetHicon());<br />
|
|
|
|
|
this also seems to work
System.Drawing.Bitmap bmp = imageList1.Images[0] as Bitmap;
System.Drawing.Icon icon = Icon.FromHandle(bmp.GetHicon());
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
Only if the images in the image list are bitmaps
|
|
|
|
|
hmmm... I ran mine off a .ico file that I used the VS2005 Icon editor to create.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
Well....after reading this thread of thought, I'm thinking that the image list was the wrong way to go. Think I'll try just putting the icons into the project resource file.
|
|
|
|
|
i am developing a SDI application.
i have to exit application from other class than Foem class.
how can i do it?
i wrote Application.Exit() in that class, but its not working..
can any body help pls
|
|
|
|