|
|
How to get information about starting new process in my c# app ?
Something like new process listener. Process would be started manualu by user.
|
|
|
|
|
Is there any packers for .NET apps such as: http://upx.sourceforge.net for win32?
Thanks
|
|
|
|
|
An installer like NSIS will have better compression results, but in this day and age, UPX isnt really useful.
|
|
|
|
|
hello,
i'm initiating an object inside a method:
private void Example ()
{
MyClass ins = new MyClass(...);
ins.AMethod();
ins.Dispose();
}
i'm wondering if the last line: ins.Dispose(); is necessary? Or C# does it automaticlly?... i mean disposing the object as soon as the method is finish.
please advise
|
|
|
|
|
xkx32 wrote: i'm wondering if the last line: ins.Dispose(); is necessary? Or C# does it automaticlly?...
To the first question - If the class has a Dispose() method then, yes, you should use it.
To the second question - If the class has a destructor (Finalizer) that calls Dispose() then, yes, it will eventually get to it. BUT, just because it will get to it eventually doesn't mean you can get all lazy about it. If a class supports Dispose() it is usually for a very good reason and its very existance suggests that you should use it.
xkx32 wrote: i mean disposing the object as soon as the method is finish
If that is where the object is naturally no longer required then that is where you should dispose of it. If you are only going to use an object within one method and it won't be stored anywhere else by the time the method completed then you may like to use the following instead
using (MyClass ins = new MyClass())
{
ins.AMethod();
} What happens here is that as soon as the code exits the scope of the using block for what ever reason (it might reach it naturally, or it might be in the process of throwing an exception) the object will be Dispose d of.
|
|
|
|
|
The Dispose method doesn't dispose of the object itself, it tells the object to dispose of the unmanaged resources that it's using.
If an object has a Dispose method, you should use it. It helps the object to free resources as soon as possible. If you don't call Dispose, you won't know when the resources will be freed.
As .NET uses garbage collection, not reference counting, the object will not be finalized immediately when there is no reference to it, but when the garbage collector does the next collection. Depending on the memory "turnover" of the program, this can be in seconds, minutes, hours... or not until the application ends.
---
b { font-weight: normal; }
|
|
|
|
|
Microsoft technicians state that you should never call Dispose and always allow the Garbage Collector to handle object management. That object exposing the IDispose method places it at the top of the list for GC to process.
|
|
|
|
|
Hi All,
I have a problem.
I want to assign the value of text control to a variable of double type.
If i do in this way
double price = Text1.Text
gives compilation error.
If I do in this way
double price = (double) Text1.Text
gives me run time error of invalidcast type.
How can I procceed in this case.
Regards
Every thing will come to you if you have faith.
|
|
|
|
|
Hello Amol Ravatale,
Every value type (i.e. int, double, char, etc.) has a Parse() function.
This functions are all static, meaning you don't need to instantiate an object of that type.
In your case, do the following:
double price = double.Parse(Text1.Text);
Best regards,
Shy.
-- modified at 11:53 Sunday 30th July, 2006
|
|
|
|
|
Double.TryParse() is what you want.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You're right... It's better that way since you can't really tell what's in the box...
|
|
|
|
|
Well, you can always catch the exception in Parse
Also, Parse is .NET 1.1, while TryParse is only .NET 2.0
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Every thing will come to you if you have faith.
|
|
|
|
|
hi every one
I just wanted to know how can we make a combo box in a datagrid. I'm working in Windows Forms and in .net 1.1.
iknow its easy to do in .net 2.0 but I'm not working in it!!
thanks in advance!
Rocky
|
|
|
|
|
im getting crazy here
i have a c# application in which i have client and server.
there is no continuing connection between them
every time the client want something , he open the connection and query...
i also have a function which called : run_sql_select_command
in it , i have try and catch if there is no database ( or other problem).
the problem is that i want , IF ERROR , IN THE CATCH , goto the login screen.
i have just 1 form.
the program going to the login and then COMEBACK to the function !!!!!!! ( i dont want it - i want it to stay at the login section)
i tried goto , but it is not in the scope,
what can i do ??
please,.
|
|
|
|
|
while(true)
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Your design is flawed, and shows a poor grasp of how .Net works works.
|
|
|
|
|
Hey all,
I'm writing a class named ShapedForm.
It inherits from System.Windows.Forms.Form.
What I'm trying to accomplish is a built in functionality to make a non-rectangular form (i.e. a shaped form), and other functionalities such as form dragging with no title-bar.
I wrote this function:
public void ShapeTheForm(Bitmap ShapeImage, Color Key)
{
if (busy) return;
busy = true;
Region trans = new Region();
trans.MakeEmpty();
int width = ShapeImage.Width;
int height = ShapeImage.Height;
for (int y = 0; y < height; ++y)
for (int x = 0; x < width; ++x)
{
Color pixel = ShapeImage.GetPixel(x, y);
if (pixel.R == Key.R && pixel.G == Key.G && pixel.B == Key.B)
trans.Union(new Rectangle(x, y, 1, 1));
}
Region tempRegion = new Region(new Rectangle(0, 0, ShapeImage.Width, ShapeImage.Height));
tempRegion.Exclude(trans);
lastStyle = FormBorderStyle;
if (InvokeRequired)
Invoke(new LayoutSetDelegate(SetShapedLayout), ShapeImage, tempRegion);
else
{
FormBorderStyle = FormBorderStyle.None;
Size = new Size(ShapeImage.Width, ShapeImage.Height);
Region = tempRegion;
BackgroundImage = ShapeImage;
}
trans.Dispose();
trans = null;
busy = false;
} It worked earlier, and I can't see the problem now.
When I call the function, the debugger lands on this line:
Region = tempRegion;
I get a StackOverflowException in System.Drawing.dll...
Do you see any problem with my code?
Any ideas why assigning the region fails?
Thanks in advance,
Shy.
|
|
|
|
|
Hi!
If it worked before and now doesn't, chances are that you changed something else...
Could it be that setting the Region property of your form calls ShapeTheForm() again and your busy -Flag doesn't work?
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Hmm... I suppose the scenario you've described above is not taking place, as I did Step-By-Step debugging and when I get to this specified line an exception is thrown...
So... There's no inifinate loop/recursion happening here...
|
|
|
|
|
Did you override/'new' Region ?
|
|
|
|
|
|
I've just discovered that if I use a different color then the transparent color as the key, no exception is thrown.
The function completes successfully, and the region stays the complete region, without any transparent parts...
|
|
|
|
|
Well... It's very strange, but if I use a GraphicsPath object instead of a Region object as the "trans" variable, it works!
|
|
|
|