473,748 Members | 2,621 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Thread blocking diagnosis

Bob
Hi,
I have an app that has a 3rd party phone answering control (4 of )
(interfacing with dialogic 4 line card) attached to the main form.
each control raises an event when its Dialogic line detects ring tone.
I use the ring detect event handler to create a new thread which is given a
reference to the control that is being rung. The called method then
interacts with the control until the call finishes.
My problem is that I believe I am getting thread blocking between the
threads that are dealing with the calls.
There doesn't appear to be any consistent pattern to the blocking and I was
wondering what techniques I can use to further investigate this. I have run
the app under a commercial profiler but there is nothing definitive showing.
Each of the phone call threads seem to get roughly the same time.
The blocking occurs when the phone handling objects are getting input from
phone users. (DTMF tones) but varies at which point it occurs.

Initiating Code from one of the four ring detect event handlers follows:
telecall te = new telecall();//Class that contains state engine to handle
call

te.TraceMessage += new telecall.TraceM essageEventHand ler(te_TraceMes sage);//
info back from state engine

te.LineStateCha nge += new
telecall.LineSt ateChangeEventH andler(this.Set LineStatus); // Phone line
status back from state engine

te.MyForm = this;//Ref to stop orphans

te.Vbocx = ((AxVbocxLibrar y.AxVBocx)(send er));//Assigning ref to the line
handling object.

ThreadStart ts = new ThreadStart(te. HandleCall);// State engine

Thread t = new Thread(ts);

t.Name = "PH1";

t.SetApartmentS tate(ApartmentS tate.STA);//desperation

t.Start();
Oct 10 '06 #1
3 3289

Bob wrote:
Hi,
I have an app that has a 3rd party phone answering control (4 of )
(interfacing with dialogic 4 line card) attached to the main form.
each control raises an event when its Dialogic line detects ring tone.
I use the ring detect event handler to create a new thread which is given a
reference to the control that is being rung. The called method then
interacts with the control until the call finishes.
My problem is that I believe I am getting thread blocking between the
threads that are dealing with the calls.
There doesn't appear to be any consistent pattern to the blocking and I was
wondering what techniques I can use to further investigate this. I have run
the app under a commercial profiler but there is nothing definitive showing.
Each of the phone call threads seem to get roughly the same time.
The blocking occurs when the phone handling objects are getting input from
phone users. (DTMF tones) but varies at which point it occurs.

Initiating Code from one of the four ring detect event handlers follows:
telecall te = new telecall();//Class that contains state engine to handle
call

te.TraceMessage += new telecall.TraceM essageEventHand ler(te_TraceMes sage);//
info back from state engine

te.LineStateCha nge += new
telecall.LineSt ateChangeEventH andler(this.Set LineStatus); // Phone line
status back from state engine

te.MyForm = this;//Ref to stop orphans

te.Vbocx = ((AxVbocxLibrar y.AxVBocx)(send er));//Assigning ref to the line
handling object.

ThreadStart ts = new ThreadStart(te. HandleCall);// State engine

Thread t = new Thread(ts);

t.Name = "PH1";

t.SetApartmentS tate(ApartmentS tate.STA);//desperation

t.Start();
>From the COM library reference, it appears that you are using an older
version of CallSuite... Those are STA Com Objects, and as such each
one must exist on it's own thread or you need to use the async methods
methods provided by the control or they will block each other. One way
I have over come this, is to write a wrapper class for the VoiceBocx
object that spawns a thread in the constructor. that intializes the
object and then calls Application.Run . I use a ManualReset Event to
signal that intialization has completed. It is complex I guess, but it
works well. I use a newer version - 9.1, and I don't use the ActiveX
control - only the object, but this code was written with the older
version originally. The code here is not all of the code, nor is it
actually working code - it is just a bit to illustrate the point:

public sealed class Trunk : System.IDisposa ble
{
private ADXVoiceClass trunk;
private ManualResetEven t intialized;
private Exception startup;

public Trunk(int channel)
{
this.startup = null;

/ set this so that we can signal initilization.. .
this.intialized = new ManualResetEven t(false);

// VoiceBocx objects need to exist on their own thread to
// avoid blocking problems. So, we will create an STA Thread,
// create the object and start a message pump for the object.
Thread runner = new Thread (new ThreadStart(thi s.ObjectThread) );
runner.Apartmen tState = ApartmentState. STA;
runner.IsBackgr ound = true;
runner.Start ();

// wait for intialization to complete.
this.intialized .WaitOne();
this.intialized .Close();
if (this.startup != null)
{
throw this.startup;
}
}

private void ObjectThread()
{
try
{
// set up the trunk object
InitializeTrunk Object();

// signal the parent!
this.intialized .Set();

// start a message loop for COM events on this thread
Application.Run ();
}
catch (Exception ex)
{
this.startup = ex;
this.intialized .Set ();
}
}

..... Lots of other junk
}

The actual working code actually lets you pass in a value to determine
if it creates a thread for the object or not. I am not saying this is
the only (or even the best way), but if you want to use multiple phone
lines in your application, then you will need to use the async model
supported by the VoiceBocx control or arrange to have each line live on
it's own thread.

Anyway,
HTH

--
Tom Shelton

Oct 10 '06 #2

Tom Shelton wrote:
Bob wrote:
Hi,
I have an app that has a 3rd party phone answering control (4 of )
(interfacing with dialogic 4 line card) attached to the main form.
each control raises an event when its Dialogic line detects ring tone.
I use the ring detect event handler to create a new thread which is given a
reference to the control that is being rung. The called method then
interacts with the control until the call finishes.
My problem is that I believe I am getting thread blocking between the
threads that are dealing with the calls.
There doesn't appear to be any consistent pattern to the blocking and I was
wondering what techniques I can use to further investigate this. I have run
the app under a commercial profiler but there is nothing definitive showing.
Each of the phone call threads seem to get roughly the same time.
The blocking occurs when the phone handling objects are getting input from
phone users. (DTMF tones) but varies at which point it occurs.
By the way, if this is CallSuite - there is a bug in the GetDigits
call. It will always pause 3 seconds, even if you tell it to return
immediately. The only way around it that I have found is to implement
my own digit buffer using the DigitDetected event.

--
Tom Shelton

Oct 10 '06 #3
Bob
Hi Tom,
Thank you for the example,
Yes, using 5.2. The penny finally dropped that although I was spawing new
threads ultimately they were refering back to the 4 controls on the parent
form. I have taken a slightly more expensive way in that I now have a form
with only one control on it and I spawn 4 of these, hide them and have them
report back to the main form via events.
Load test today. (Heres hoping:-))
regards
Bob
"Tom Shelton" <to*@mtogden.co mwrote in message
news:11******** *************@k 70g2000cwa.goog legroups.com...
>
Bob wrote:
Hi,
I have an app that has a 3rd party phone answering control (4 of )
(interfacing with dialogic 4 line card) attached to the main form.
each control raises an event when its Dialogic line detects ring tone.
I use the ring detect event handler to create a new thread which is
given a
reference to the control that is being rung. The called method then
interacts with the control until the call finishes.
My problem is that I believe I am getting thread blocking between the
threads that are dealing with the calls.
There doesn't appear to be any consistent pattern to the blocking and I
was
wondering what techniques I can use to further investigate this. I have
run
the app under a commercial profiler but there is nothing definitive
showing.
Each of the phone call threads seem to get roughly the same time.
The blocking occurs when the phone handling objects are getting input
from
phone users. (DTMF tones) but varies at which point it occurs.

Initiating Code from one of the four ring detect event handlers follows:
telecall te = new telecall();//Class that contains state engine to
handle
call

te.TraceMessage += new
telecall.TraceM essageEventHand ler(te_TraceMes sage);//
info back from state engine

te.LineStateCha nge += new
telecall.LineSt ateChangeEventH andler(this.Set LineStatus); // Phone line
status back from state engine

te.MyForm = this;//Ref to stop orphans

te.Vbocx = ((AxVbocxLibrar y.AxVBocx)(send er));//Assigning ref to the
line
handling object.

ThreadStart ts = new ThreadStart(te. HandleCall);// State engine

Thread t = new Thread(ts);

t.Name = "PH1";

t.SetApartmentS tate(ApartmentS tate.STA);//desperation

t.Start();
From the COM library reference, it appears that you are using an older
version of CallSuite... Those are STA Com Objects, and as such each
one must exist on it's own thread or you need to use the async methods
methods provided by the control or they will block each other. One way
I have over come this, is to write a wrapper class for the VoiceBocx
object that spawns a thread in the constructor. that intializes the
object and then calls Application.Run . I use a ManualReset Event to
signal that intialization has completed. It is complex I guess, but it
works well. I use a newer version - 9.1, and I don't use the ActiveX
control - only the object, but this code was written with the older
version originally. The code here is not all of the code, nor is it
actually working code - it is just a bit to illustrate the point:

public sealed class Trunk : System.IDisposa ble
{
private ADXVoiceClass trunk;
private ManualResetEven t intialized;
private Exception startup;

public Trunk(int channel)
{
this.startup = null;

/ set this so that we can signal initilization.. .
this.intialized = new ManualResetEven t(false);

// VoiceBocx objects need to exist on their own thread to
// avoid blocking problems. So, we will create an STA Thread,
// create the object and start a message pump for the object.
Thread runner = new Thread (new ThreadStart(thi s.ObjectThread) );
runner.Apartmen tState = ApartmentState. STA;
runner.IsBackgr ound = true;
runner.Start ();

// wait for intialization to complete.
this.intialized .WaitOne();
this.intialized .Close();
if (this.startup != null)
{
throw this.startup;
}
}

private void ObjectThread()
{
try
{
// set up the trunk object
InitializeTrunk Object();

// signal the parent!
this.intialized .Set();

// start a message loop for COM events on this thread
Application.Run ();
}
catch (Exception ex)
{
this.startup = ex;
this.intialized .Set ();
}
}

.... Lots of other junk
}

The actual working code actually lets you pass in a value to determine
if it creates a thread for the object or not. I am not saying this is
the only (or even the best way), but if you want to use multiple phone
lines in your application, then you will need to use the async model
supported by the VoiceBocx control or arrange to have each line live on
it's own thread.

Anyway,
HTH

--
Tom Shelton

Oct 10 '06 #4

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

Similar topics

4
7768
by: John P. Speno | last post by:
So you have this problem, and you decide to use threads to solve it... System is Python 2.3.3 on Solaris 9. I'm using the classic Python thread model. Main thread puts stuff into a Queue.Queue() and worker threads get stuff out of it and do their thing. On occaision, I get an exception in the main thread when it tries to put something into the Queue.
3
2221
by: David Sworder | last post by:
This message was already cross-posted to C# and ADO.NET, but I forgot to post to this "general" group... sorry about that. It just occured to me after my first post that the "general" group readers might have some thoughts on this perplexing .NET blocking issue. (see below) ===== Hi,
44
2368
by: Charles Law | last post by:
Hi guys. I'm back on the threading gig again. It's the age-old question about waiting for something to happen without wasting time doing it. Take two threads: the main thread and a worker thread. The worker thread is reading the serial port, waiting for something to happen (a service request). When it does it raises an event. Of course, the event is executed on the worker thread. The idea is that when the event is raised, the handler...
2
12680
by: Bruce Vander Werf | last post by:
How can I cleanly stop a thread that is currently blocking on Socket.Receive? I don't want to use Thread.Abort, because I would like the thread method to exit cleanly, and the same code must run under the Compact Framework, which does not support Abort. Will Socket.Close cause the Receive method to finish, or is there a better way?
7
2868
by: David Sworder | last post by:
Hi, I'm developing an application that will support several thousand simultaneous connections on the server-side. I'm trying to maximize throughput. The client (WinForms) and server communicate via a socket connection (no remoting, no ASP.NET). The client sends a message to the server that contains some instructions and the server responds in an asynchronous fashion. In other words, the client doesn't block while waiting for the...
6
4125
by: roger beniot | last post by:
I have a program that launches multiple threads with a ThreadStart method like the following (using System.Net.Sockets.Socket for UDP packet transfers to a server): ThreadStart pseudo code: Connect Receive response Send Connect ACK
6
5479
by: Joe HM | last post by:
Hello - I have a function that calls Thread.Abort() to stop a thread in a _Closed() Method of a GUI. The thread contains a blocking call on a TCP socket and that is the easiest way to stop that. This thread is also outputting strings in a RichTextBox and in some rare instances I get a System.NullReferenceException when I exit the GUI. It seems like the _Closed() Method calls Thread.Abort() and then continues closing down/disposing...
18
10243
by: =?Utf-8?B?VGhlU2lsdmVySGFtbWVy?= | last post by:
Because C# has no native SSH class, I am using SharpSSH. Sometimes, for reasons I do not know, a Connect call will totally lock up the thread and never return. I am sure it has something to do with weirdness going on with the server I am talking to. Anyhow, this locked up state happens once in a while (maybe once per day) and I can't figure out how to deal with the locked up thread. If I issue a Thread.Abort() the exception never...
1
1710
by: =?Utf-8?B?QU1lcmNlcg==?= | last post by:
Sorry this is so long winded, but here goes. Following the model of http://msdn2.microsoft.com/en-us/library/system.runtime.remoting.channels.ipc.ipcchannel.aspx I made a remote object using the IpcChannel Class (vs 2005, vb, fw 2.0). Everyting works fine. The object is registered with WellKnownObjectMode.Singleton The remote object appears at the bottom of this posting. The code is deliberately obtuse to expose an issue about when...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9386
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.