Solved

Preventing multiple events calling a running  thread

Posted on 1998-12-16
2
168 Views
Last Modified: 2010-04-04
I am designing a server application using TCP/IP (TServerSocket).  An event is generated each time a request is recieved.  I have a que attached to one thread, when a message is added to the Que the que needs to call the thread if is not already running.  How do I do this without using flags (serverbusy true/false) and ensure that the event ends while the thread is running?.    
0
Comment
Question by:RobMartin
2 Comments
 

Author Comment

by:RobMartin
ID: 1351395
This problem seems similar to that an OS faces when handling multiple programs attempting to access one resource.  How does the OS block the request if active and then notif the app when it becomes free.
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 100 total points
ID: 1351396
If you want to serialise access by these events to the thread then use critical sections (eg:EnterCriticalSection et al).

If you just want the event to abort if the thread is running you can do this a number of ways eg:

1. Checking the existence of the thread object if you create one when you need it.
2. By checking the suspended state of the thread if it suspends itself when it is dones

eg: if the thread suspends itself when it is done you can do this:

if ProcessorThread.Suspended then
  begin
    // Set some properties of the thread
   ...
   // activate thread again
  ProcessorThread.Suspended := false;
  end
else
  // abort processing this event.


Cheers,

Raymond.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question