|
hi ,
anyone know if this is a confirmed bug?:
if i create a system.windows.forms.timer in a usercontrol , and attach an eventhandler to the timer , and set the timer.enabled = true.
the usercontrol can NOT get finalized nor disposed unless you either close the host application or call the .dispose() on the usercontrol yourself...
//Roger
|
|
|
|
|
Its not a bug. Its like that by design, as the timer still is being referenced, the GC will not clean it up, unless you close its parent container or call dispose explicitly.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
no , that is not true , all other eventhandlers are weak references , they does not keep the parent alive.
and in this case you can actually do:
---
system.windows.forms.timer t=new system.windows.forms.timer();
t.tick +=new eventhandler(this.somemethod);
t.enabled=true;
t=null;
g.collect();
---
in the above case , the timer will still be alive after you set t=null..
if you do the same with any other control they are gc'ed directly , even if they have eventhandlers on them...
there fore this problem prevents the parent of the timer to be disposed / finalized when the parent goes out of scope (unless you call .dispose yourslef or exit the host app) , since the timer for some reason holds a strong ref to the parent...
//Roger
|
|
|
|
|
When you add a Forms timer, this constructor is invoked:
this.timer1 = new System.Windows.Forms.Timer(this.components);
Thus it is still referenced in the containers components. To solve you problem I would just dispose of the timer or use System.Timers.Timer, but that wont run in the same thread as the form and could cause problems.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
not true either
same thing applies if the timer is created w/o the components param.
as:
system.windows.forms.timer t=new system.windows.forms.timer();
//Roger
|
|
|
|
|
I'm looking for info on Bluetooth programming. Anyone know of ANY sources other than the 3 pages you get on MSDN?
Me, wrong!?! Nah, you just need to change your thinking to make me right.
|
|
|
|
|
You probably have but: https://www.bluetooth.org/[^]
Some forums on there which might help as well.
Paul Watson Bluegrass Cape Town, South Africa
Macbeth muttered:
I am in blood / Stepped in so far, that should I wade no more, / Returning were as tedious as go o'er
DavidW wrote:
You are totally mad. Nice.
|
|
|
|
|
Thanks, nothing there I could find.
Me, wrong!?! Nah, you just need to change your thinking to make me right.
|
|
|
|
|
There is some kind of limitation about calling a web method from a timer method.
In my case the HelloWorld WebMethod is called in a client thread after every Second (Also tried other time intervals) but after making teh 18th call it stops calling.
The same method is called any number of times when called from a for loop rather then a timer method....
What can be the problem?
|
|
|
|
|
Hi ,
i have a control , which holds refs to 2 forms.
the 2 forms also holds refs to the control ..
when the control is initialized , the forms are created (invisible)
the forms are dialogs that should allow customization of the control...
this all works fine , and as far as i know , .net should be able to deal with circulair refs , (that was one main reason for ditching COM , right?)
now to the problem...
if i use the control on a host form , and then decide to remove / kill the form.
the control still resides in memory , since the child dialogs references it , and windows can apparently exist w/o any direct reference to them. so the child dialogs are alive and kicking and keeping the control ref alive...
so say that i have a MDI app , and place my control on a MDI Child , then i close the mdi child , and the control will still reside in memory...
what would be the best way to solve this?????
when a container (like a form) is garbagecollected , does it call dispose on all the child controls then???
//Roger
|
|
|
|
|
For the life of me I can't differentiate between these two classes. Whatever I try, I seem to end up thinking they are the same. Can someone explain to me with a small example how they differ and how any one Group from a Match class's GroupCollection will have a CaptureCollection with greater than 1 Capture objects. Thanks in advance.
Regards
RegExp Noo-Bee
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Sure. If you're doing a match like:
(?<test> .*? )
I capture strings of non-space characters to the Test capture.
I can use a quantifier on this:
(?<test> .*? )+
If I do this, there will be more than one capture to Test, and they are accessed through the capture collection
|
|
|
|
|
|
|
|
I'm trying to launch the default browser, with a given URL in a particular event handler. The best I have so far is:
using (RegistryKey rkey = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Classes\http\shell\open\command"))
{
string val = rkey.GetValue(String.Empty).ToString();
string browser = val.Split('\"')[1];
Process.Start(browser, URL);
} This works perfectly well on my machine but IE is the only browser I have installed, let alone the default.
Can anyone tell me
a) If there's a better place to look for the default browser and
b) If Netscape, Opera, et al can be parsed out of that key using the same Split?
Paul
We all will feed the worms and trees So don't be shy - Queens of the Stone Age, Mosquito Song
|
|
|
|
|
Key 1 :
HKCR\.html ==> htmlfile
Key 2 :
HKCR\htmlfile\shell\open\command ==> "c:\....\iexplore.exe" | "...\netscape.exe" | "...."
|
|
|
|
|
I did think about using ".html" but I figured it was possible, if unlikely, that someone might have it set up so that double-clicking an .html file would open a different browser from the default.
Daniel seems to have the perfect answer, but thanks anyway
Paul
We all will feed the worms and trees So don't be shy - Queens of the Stone Age, Mosquito Song
|
|
|
|
|
Just call Process.Start(URL) and it'll call the default browser for you.
It's not the fall that kills you: it's the sudden stop - Down by Law, Jim Jamursch (1986)
|
|
|
|
|
Nice answer Daniel. Didn't really give much thought to that idea, I didn't think it would work with a URL like "www.mydomain.com/mysite" (ie. no mention of http or html) but somehow it does. Very cool, thanks.
Paul
We all will feed the worms and trees So don't be shy - Queens of the Stone Age, Mosquito Song
|
|
|
|
|
i would like to add line numbers to a richTextBox, does anyone know of an easy way of doing this?
i was thinking about having two text boxes controlled by the same scroll bar but i dont know how to link them up?
or is it easier to use a different control to add the line numbers?
Any help would be extreemly useful as i dont remember seeing an example of this or anything similar anywhere!
|
|
|
|
|
I was thinking about how to design a custom control with the same functionality for the richTextBox. My initial approach would be to use a panel along the left side and set its dock property to left and the richTextBox to fill. I think there would have to be some sort of callback to the panel so it knows to update the line numbers.
I do not know if this is the correct approach but it could be a start for further discussion on this topic.
I would be interested in seeing the best method to do this.
Regards,
Brandon
|
|
|
|
|
My only reason for thinking of using two of the same text controls was an easy way to keep line numbers in the correct place as they could both share the same font and would have equal spaces in the line numbering i thought it would then be a simple task to get them to scroll together and somehow lock the textbox displaying the numbers so that it wouldn't highlight or selct on click, it would just appear next to it.
|
|
|
|
|
Can anyone tell me how can I obtain the HINSTANCE of my app in C#?
Thanks a lot,
Andrei Matei
andreimatei@home.ro
Andrei Matei
andreimatei@home.ro
|
|
|
|
|
System.Diagnostics.GetCurrentProcess().Handle
|
|
|
|