Threads on an Intermec 751 plist

P

ppanchal

We have a C# .NET application running on a Intermec 751 device. The O/S
is Pocket PC Version 4.20.0 (Build 14053). We are running CF version
1.0.4292.00. We are also using OpenNetCf.

When looking at our process list our multi form application sometimes
has a very high thread count. Our app is TAP.exe.

name pid threads
NK.EXE 0x181FF002 001
filesys.exe 0x981EE8CA 006
device.exe 0x58186626 066
gwes.exe 0x381EED6E 017
services.exe 0x77F1CF7A 009
KeyIcon.exe 0x37D505EE 002
shell32.exe 0x17EF941E 004
srvtrust.exe 0x57EAB946 005
connmgr.exe 0x37EFA002 002
ftpdce.exe 0x17A50EC2 004
DataServer.exe 0x57C1C0CE 012
TAP.exe 0x178EDE9A 034
Monitor.exe 0x97CCEAAA 001
IQueueCE.exe 0xF76B958A 004
SSClient.exe 0x376B9566 007
ndistray.exe 0xD7BA0B16 001
poutlook.exe 0x97B5CBE6 001

Is there a way to figure out what is causing new threads. We have
noticed once we get to the mid 200s our application starts experiencing
problems. Typically we see about 2 threads get added when a new forms
is loaded, after the form is closed/disposed, the thread count
decreases. Some devices periodically start creating threads. I have not
been able to diagnose
what is causing the high thread count.
 
G

Guest

There's nothing inherent in the CF that just creates threads without being
told to do so. Your app is creating the threads - the only one who can say
exactly how or why would be you, since it's your code.
 
P

ppanchal

In our code there is only one instance where we use a thread, however I
am thinking some method or dll we are using in our project may be
causing it. It seems with every form I load I seem to add 2-3 threads.
After closing or disposing the forms, I get the thread back.

We have use Process Explorer form madebits.com and can see all the
threads, I just don't know how to tell what is causing all these
threads. Is there a way to identify what the thread is or what is doing?
 
S

Simon Hart

What are your forms doing? can you post some code and also post the code
where you are using the thread class or using the ThreadPool, are you using
the ThreadPool anywhere?

Regards
Simon.
 
P

ppanchal

Not using a thread pool. I've stripped down our code to simplify how we
are using our thread classes.

We use a thread to process cached web service calls in the background
of the mainline application.
We only have one instance of this thread running when we are unable to
execute web service calls
successfully.

using System.Threading;

private void startDisconnectedThread()
{
Thread disconnectProcessor = new Thread(new
ThreadStart(DisconnectedProcessor));
disconnectProcessor.Start();
}

private void DisconnectedProcessor()
{
// Run in background until method is complete.
// I have not posted actual code, but this method is
// a while loop that execute until messages are processed.
// Only one instance of this thread can be run.
}

We are also using the timerCallback to have code execute after a time
limit.

private void frm_Load(object sender, System.EventArgs e)
{
Application.DoEvents();
System.Threading.TimerCallback splashDelegate = new
System.Threading.TimerCallback(this.Start_Loading);
this.splashTimer = new System.Threading.Timer(splashDelegate, null,
100, 0);
}

public void Start_Loading(object o)
{
bool bSuccess = true;
if (!LoadRegistrySettings())
bSuccess = false;
if (!LoadIntermecSettings())
bSuccess = false;
if (!bSuccess)
MessageBox.Show("Return device to office. Configuration error.");
splashTimer.Dispose();
Application.Run(new TAPMainMenu());
Application.Exit();
}

We also use the timerCallback in web service calls to time out the
call:

try
{
System.Threading.Timer serviceTimeout = new System.Threading.Timer(new
TimerCallback (this.ServiceTimeout), service, SERVICE_TIMEOUT,
SERVICE_TIMEOUT);
user = service.LogonUser(global.GetDevice().DeviceID, scanFlag,
employeeId);
}
catch(SoapException soapEx)
{
exceptionCode = soapEx.GetBaseException().Message;
}
catch(Exception ex)
{
exceptionCode = ex.Message;
}

public void ServiceTimeout(object obj)
{
try
{
((System.Web.Services.Protocols.SoapHttpClientProtocol)obj).Abort();
}
catch (Exception e)
{
LogDeviceException("WebServiceProxy","ServiceTimeout",e.Message);
}
}
 
G

Guest

The Threading.Timer creates a thread when it fires. I don't see you calling
Dispose on it, so the fact that you're getting a lot of these zombie threads
doesn't surprise me. If you cause a full collection (e.g. send your app to
the background) do they all get cleaned up?
 
P

ppanchal

I have sent the app to the background and it does not clear up the
threads when they are building. We are disposing the thread timer in
most places, code was not posted.

I have watched our application remotely while QA runs thru several
areas. I have seen the thread cound go as high as 35 and drop down to
15-17 or so on our main menu.

I have also run a test run where I triggered something, and no matter
where I was in the application more and more threads were being
created. It's hard for me to recreate the situation.

There is only one situation where I can solidly cause this thread
problem. If I warm boot the device, and let the application start up on
a powered dock, and do not touch it. Let it sit on the logon screen.

1) Our app starts up and loads a splash page.
2) On the splash page, we load registry settings first.
3) We load vendor specific setting next (Intermec)
4) Then we load application specific location settings using web
services.
5) Then we load our main menu form, which looks for a global employee
being loaded.
6) If the employee is not loaded, we throw up a logon page.

After all this completes TAP.exe has 17 threads. If I log in, I have 15
threads. If I logout
I go back to 17 threads, and the issue does not occur. If I do not
touch the device, after about a minute or so, threads get added 1 by 1.
I'd say about 1 per minute or so.

If I let the thread count go to 75 or so, and login, the threads reset
to 15. If I let the thread count go to 270, the application bombs and I
get the expection screen but all blank.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top