473,383 Members | 1,829 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,383 software developers and data experts.

Dispose method not doing its job


I am using TimerCallback to call a method in an activex dll repeatedly. The
TimerCallback works fines but when i exit the program, it still shows up in
the taskmgr i.e still running. So i use the Dispose method to release
resource from the thread on closing but still it doesn't work. I was
thinking whether it was the dll the culprit, which is better out process or
something else?

static System.Threading.Timer tr;

private void run(object state){
long value = test.MonitorRAS();
switch(value){
case 1:MessageBox.Show("Connected");break;
case 0:MessageBox.Show
("Disconnected");break;
}
}

private void Callback(){
TimerCallback call = new TimerCallback(run);
tr = new System.Threading.Timer
(call,null,0,20);
}
Nov 15 '05 #1
4 1520
Please post a complete repro, the snippet you posted doesn't show the
Dispose method's implementation.
Are you running this on a separate thread? If it is, make sure it's a
backgroud thread otherwise the process will not terminate if the threadproc
is in an endless loop.

Willy.

"Merlynx" <no****@home.com> wrote in message
news:Ot**************@tk2msftngp13.phx.gbl...

I am using TimerCallback to call a method in an activex dll repeatedly. The TimerCallback works fines but when i exit the program, it still shows up in the taskmgr i.e still running. So i use the Dispose method to release
resource from the thread on closing but still it doesn't work. I was
thinking whether it was the dll the culprit, which is better out process or something else?

static System.Threading.Timer tr;

private void run(object state){
long value = test.MonitorRAS();
switch(value){
case 1:MessageBox.Show("Connected");break;
case 0:MessageBox.Show
("Disconnected");break;
}
}

private void Callback(){
TimerCallback call = new TimerCallback(run);
tr = new System.Threading.Timer
(call,null,0,20);
}

Nov 15 '05 #2
The Dispose method is implemented in an event handler closing. No it is not
a background thread.

--
Come on,do your worst...make me laugh!!
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:uV**************@TK2MSFTNGP12.phx.gbl...
Please post a complete repro, the snippet you posted doesn't show the
Dispose method's implementation.
Are you running this on a separate thread? If it is, make sure it's a
backgroud thread otherwise the process will not terminate if the threadproc is in an endless loop.

Willy.

"Merlynx" <no****@home.com> wrote in message
news:Ot**************@tk2msftngp13.phx.gbl...

I am using TimerCallback to call a method in an activex dll repeatedly.

The
TimerCallback works fines but when i exit the program, it still shows up

in
the taskmgr i.e still running. So i use the Dispose method to release
resource from the thread on closing but still it doesn't work. I was
thinking whether it was the dll the culprit, which is better out process

or
something else?

static System.Threading.Timer tr;

private void run(object state){
long value = test.MonitorRAS();
switch(value){
case 1:MessageBox.Show("Connected");break; case 0:MessageBox.Show
("Disconnected");break;
}
}

private void Callback(){
TimerCallback call = new TimerCallback(run);
tr = new System.Threading.Timer
(call,null,0,20);
}


Nov 15 '05 #3

When I read this "the Dispose method to release resource from the thread on
closing but ", I assume you call Dispose from another thread than the Main
thread. Are you sure you return from the thread procedure after the call.
Remember non-background threads don't terminate when the main thread
terminates, this will prevent the process to terminate.

Willy.

"Merlynx" <no****@home.com> wrote in message
news:Oo**************@tk2msftngp13.phx.gbl...
The Dispose method is implemented in an event handler closing. No it is not a background thread.

--
Come on,do your worst...make me laugh!!
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:uV**************@TK2MSFTNGP12.phx.gbl...
Please post a complete repro, the snippet you posted doesn't show the
Dispose method's implementation.
Are you running this on a separate thread? If it is, make sure it's a
backgroud thread otherwise the process will not terminate if the

threadproc
is in an endless loop.

Willy.

"Merlynx" <no****@home.com> wrote in message
news:Ot**************@tk2msftngp13.phx.gbl...

I am using TimerCallback to call a method in an activex dll
repeatedly.
The
TimerCallback works fines but when i exit the program, it still shows
up in
the taskmgr i.e still running. So i use the Dispose method to release
resource from the thread on closing but still it doesn't work. I was
thinking whether it was the dll the culprit, which is better out
process or
something else?

static System.Threading.Timer tr;

private void run(object state){
long value = test.MonitorRAS();
switch(value){
case

1:MessageBox.Show("Connected");break; case 0:MessageBox.Show
("Disconnected");break;
}
}

private void Callback(){
TimerCallback call = new TimerCallback(run);
tr = new System.Threading.Timer
(call,null,0,20);
}



Nov 15 '05 #4

Thanks. you have given some hints :)

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:O7*************@TK2MSFTNGP11.phx.gbl...

When I read this "the Dispose method to release resource from the thread on closing but ", I assume you call Dispose from another thread than the Main
thread. Are you sure you return from the thread procedure after the call.
Remember non-background threads don't terminate when the main thread
terminates, this will prevent the process to terminate.

Willy.

Nov 15 '05 #5

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

Similar topics

11
by: Ken Durden | last post by:
I am in search of a comprehensive methodology of using these two object cleanup approaches to get rid of a number of bugs, unpleasantries, and cleanup-ordering issues we currently have in our...
10
by: Henrik Dahl | last post by:
Hello! After I've finished using an instance of the SqlCommand class, should I then invoke Dispose() on the instance. I suppose so, as there is a Dispose method, but what does it actually...
24
by: Jazper | last post by:
hi i have this problem. i made a class deverted by CRootItem with implementation of IDisposable-Interface. i made a test-funktion to test my Dispose-Method.... but when set a breakpoint in my...
3
by: Vagabond Software | last post by:
Scenario: The end-user selects File-Save from my applications (WinForm) menu, specifies a filename, and waits waits for my app to write the contents of a dataset to an Excel workbook. The...
11
by: Leon | last post by:
Are dataset automatically stored in memory? Does the dispose() method automatically dispose of the dataset in the code below? Do I have to dispose a dataset from memory or does the dataset...
6
by: Teresa | last post by:
1) If I do want to keep an object alive throughout the live of an application, how can I ensure that the GC doesn't clean it up? 2a) How do I determine if an object is a managed or an unmanged...
8
by: Howard Kaikow | last post by:
I've been trying to convert the following C# Dispose to VB .NET: protected override void Dispose(bool disposing) { if (excelThread != null) {
156
by: Dennis | last post by:
Ok, I'm trying to dispose of every object that I create that has a dispose method based on advice from this newsgroup. However, I'm not sure how to dispose of the following object that was created...
13
by: Grafix | last post by:
All - As we all know, Dispose method is reserved in C++ 8 and the expected syntax is to use ~MyClass(). In 1.1, we used to have following structure for Dispose class MyClass : IDisposable {...
71
by: active | last post by:
In the main program I check to see if a certain form has been disposed. Does it make sense in that form's FormClosed event to do: Me.Dispose to make sure it is disposed the next time I check. Or...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.