Terminating User-Interface Thread

Good day to all.

I would like to know how to delete a thread even if the if it is still 
running.

Thank you very much in advance.


0
delvsb (7)
7/26/2005 9:47:05 AM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
685 Views

Similar Articles

[PageSpeed] 0

delvsb wrote:
> Good day to all.
> 
> I would like to know how to delete a thread even if the if it is still 
> running.
> 
> Thank you very much in advance.

When you create the thread you must create it suspended, set 
m_bAutoDelete false, then ResumeThread.

In the main thread, signal the thread to end itself with 
PostThreadMessage.  In the UI thread message handler, free things and 
call PostQuitMessage(0);

In the main thread, WaitForSingleObject on the thread handle. Then 
delete the thread object.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
7/26/2005 1:47:43 PM
On Tue, 26 Jul 2005 02:47:05 -0700, delvsb wrote:

> Good day to all.
> 
> I would like to know how to delete a thread even if the if it is still 
> running.
> 
> Thank you very much in advance.

My Threads FAQ talks about this:

http://members.cox.net/doug_web/threads.htm

-- 
Doug Harrison
Microsoft MVP - Visual C++
0
dsh (2498)
7/26/2005 3:22:27 PM
Thank you very much for the reply.

When PostQuitMessage(0) is used, the application will exit automatically. I 
only need something that will stop executing the thread while it is still 
running without exiting the application..
My project is about searching a string in a list. I used thread so that the 
user can start and stop searching.

Please help me with this....Thank you very much in advance.

"Scott McPhillips [MVP]" wrote:

> delvsb wrote:
> > Good day to all.
> > 
> > I would like to know how to delete a thread even if the if it is still 
> > running.
> > 
> > Thank you very much in advance.
> 
> When you create the thread you must create it suspended, set 
> m_bAutoDelete false, then ResumeThread.
> 
> In the main thread, signal the thread to end itself with 
> PostThreadMessage.  In the UI thread message handler, free things and 
> call PostQuitMessage(0);
> 
> In the main thread, WaitForSingleObject on the thread handle. Then 
> delete the thread object.
> 
> -- 
> Scott McPhillips [VC++ MVP]
> 
> 
0
delvsb (7)
7/27/2005 2:31:02 AM
delvsb wrote:
> Thank you very much for the reply.
> 
> When PostQuitMessage(0) is used, the application will exit automatically. I 
> only need something that will stop executing the thread while it is still 
> running without exiting the application..
> My project is about searching a string in a list. I used thread so that the 
> user can start and stop searching.
> 
> Please help me with this....Thank you very much in advance.
> 

The steps I outlined are for terminating a secondary UI thread from the 
main thread.  If your question is how can the secondary UI thread 
terminate itself, it should call PostQuitMessage(0).  This does not 
cause the application to exit.  If you call it from the secondary thread 
it causes the secondary thread to exit.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
7/27/2005 5:17:11 AM
Hi,

No need to perform message handling; but  to use PostThreadMessage:

PostThreadMessage(m_pThread->m_nThreadID, WM_QUIT, 0, 0);

-- 
======
Arman


"Scott McPhillips [MVP]" wrote:

> delvsb wrote:
> > Good day to all.
> > 
> > I would like to know how to delete a thread even if the if it is still 
> > running.
> > 
> > Thank you very much in advance.
> 
> When you create the thread you must create it suspended, set 
> m_bAutoDelete false, then ResumeThread.
> 
> In the main thread, signal the thread to end itself with 
> PostThreadMessage.  In the UI thread message handler, free things and 
> call PostQuitMessage(0);
> 
> In the main thread, WaitForSingleObject on the thread handle. Then 
> delete the thread object.
> 
> -- 
> Scott McPhillips [VC++ MVP]
> 
> 
0
armancho_x1 (249)
7/27/2005 9:27:03 AM
Reply:

Similar Artilces:

Users cannot login to Company
Hello, Please help. We have a server (call it sql01) for our Dynamics GP 9.0. We decided to get a new server (call it sql02) to replace this because it kept going off. We have copied all the company files to the new server (attached .mdf and ..ldf files). However, on new server only user "sa" can login into Dynamics at the moment - no matter what we do. All other users get the error msg - "This login failed. Attempt to login again or contact your system administrator." BUT they can login well if we use the old server. Kindly assist me - what did we do wrong? Thank...

Second User?
Is it possible to set up a second user in Money 2002? We want to keep the data, payees, transactions, etc...separate. An alternative to File|Open is file shortcuts on each user's desktop. "Myrna Larson" <myrnalarson@charter.net> wrote in message news:ulbuQ2mbDHA.2632@TK2MSFTNGP12.phx.gbl... > Set up a 2nd file for the 2nd user. Use File/Open to switch files. > > "Chris" <CDoverspik@aol.com> wrote in message > news:0a8c01c36e6a$73e2d4a0$a001280a@phx.gbl... > > Is it possible to set up a second user in Money 2002? We > > want to kee...

How to comp/lnk an interface layer between a .NET 2003 app and VS6
Hi, I am currently trying to get an interface layer working between an app that is written in .NET 2003 as Multithreaded DLL and an SDK that provides a DLL compiled as Multithreaded in VS6. The app is not ours so we can't touch that. It provides a HAL framework, which in essence is the interface layer that needs to be filled in using our SDK. The current problem exposes random access violations and the debugger shows them happening in new or delete's. It behaves differently with release and/or debug mode, but crashes appear in both. We currently use VS6 to build the interface ...

User Form Coding
Hi All Could somebody look at my coding (below) I have a user form that makes appointsments by adding data to a booking sheet. That works fine. But I have also have a command button to open another form to cancel or reshedule the appointments. In order to find a client and the appointment details I use the below code. But I can't seem to get it to work. Any help please. Appoitment worksheet A..........B...........C................D......................E..........F........G.....H custID..Surname..First Name..Contact number..Salon..Date..Time..Treatment Bookings worksheet A..........B......

users in outlook getting email in Japanese
Users are getting their email in japanese. Could anyone help me resolve this issue. It started few months ago but only limited to mail box quota alerts but now actual messages are coming in japanese and the message body is in English. Do you have Japanese users in your enviroment? Ruban "Fasih Ahmed" <Fasih Ahmed@discussions.microsoft.com> wrote in message news:F40AE49F-CADA-40AD-AB34-62A268A5B895@microsoft.com... > Users are getting their email in japanese. Could anyone help me resolve > this > issue. It started few months ago but only limited to mail box quo...

Modal dialog not always receiving user defined messages from PostMessage()
Hi everybody, I have a simple dialog based application that reads data from a serial port in a worker thread (MonitorSerialPort()). When the worker thread detects data, it uses PostMessage() to send a message to a custom class that I derived from CWnd (CSerialDataProcessor). CSerialDataProcessor takes the raw data from the serial port and parses it into application specific format. It then posts a message to a modal dialog and the modal dialog in response to this message updates a control to display the parsed data to the user. This scheme works for the most part, however, when I stress test...

CreateFileMapping return ERROR_ACCESS_DENIED in Terminal Server environment
InitializeSecurityDescriptor(&SecurityDescriptor, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorSacl(&SecurityDescriptor, false, NULL, true); SetSecurityDescriptorDacl(&SecurityDescriptor, true, NULL, false); SetSecurityDescriptorOwner(&SecurityDescriptor, NULL, false); SetSecurityDescriptorGroup(&SecurityDescriptor, NULL, false); // SecurityAttribute.bInheritHandle = false; SecurityAttribute.lpSecurityDescriptor=&SecurityDescriptor; SecurityAttribute.nLength=sizeof(SecurityDescriptor); // hMapObject = CreateFileMapping( INVALID_HANDLE_...

WinMail.Dat Attachments Between InterOffice Users...
Hi All, we have two exchange server 2003 servers. one in NY and one in London. client is running outlook 2003. the two offices are connected via a WAN Link. when one user sends a big (over 7-8mb) power point presentation from one office to another user in the other office, the recepient gets a winmail.dat attachment instead of the ppt attachment. these emails are not going over the internet. when they send small attachments, no problems occur. Both offices are using Rich Text Format to send emails. when using html format, it works sometimes and sometimes it does not and the user g...

The node should show only for users in the AdminCalendar role
Below is part on my web.sitmap file. What I wanted to happen is for the last node to show only for users in the AdminCalendar role. But it shows always. How can I fix that? <siteMapNode title="Home" url="Home/Home.aspx" description="Go to the The Home Page" > ....snip <siteMapNode title="Calendar" roles="*" description="Time an Location of events" > <siteMapNode title="Monthly Calendars" url="Calendar/EventsCalendar.aspx" description="Calendar of events&...

Find contacts across exhange server users
I am trying to figure out how to search for a specific contact across multiple users in our intranet. Any help would be GREATLY appreciated. Thanks! --Jorge-- ...

Watching Threads I Start
Running Live Mail under W7 I have 'Mark threads I start as watched' checked. My first post when I start a thread shows up red but replies to that thread do not. If I have view set to show 'hide read messages' they replies are not in red and I have missed some replies. How do I get, if possible, all the replies to my thread to show as watched? Thank you. wysiwyg -- ....winston ms-mvp mail "Jack Gillis" wrote in message news:uD1NZJtTLHA.4980@TK2MSFTNGP04.phx.gbl... Running Live Mail under W7 I have 'Mark threads I start as w...

wizard interface
I am trying to design a wizard interface with mfc. I'm attempting to create each "panel" separately and load/unload them into the "wizard" form (with next, back, cancel) at runtime. However, I'm not familiar enough with mfc to accomplish this. I've created each "panel" as a dialog. Is there a better way to handle this? TIA On 10 Feb 2006 07:33:10 -0800, dotnetchic wrote: > I am trying to design a wizard interface with mfc. I'm attempting to > create each "panel" separately and load/unload them into the "wizard" &g...

Messaging interface has returned an unknown error #4
I have a user who gets errors when they try to print other users calendars. The error is "The messaging interface has returned an unknown error. It the problem persists, restart Outlook. I have done this and nothing helps. I have tried starting in safe mode and still get the same error. I have applied service pack 1 to office and still receive the error. The user said they could do this yesterday. Overnight her computer was upgraded from office xp to office 2003, but she already had Outlook 2003 so that was not upgraded. Any ideas would be appreciated. thanks, Mike ...

EX 2K: One user unable to receive external email
I have a user whose email account can send email in and out of the domain but cannot receive email from outside the domain. All external email are processed first by a Barracude Spam Firewall, but it's logs say that it is allowing messages for this account; so it seems to be an Exchange issue. I disconnected the mailbox, created a new one, and tested it. It, too, received internal mail but no external mail; so I killed that one and reattached the old one. Had the new mailbox worked, I would have tried ExMerging the old data into the new mailbox. Since both mailboxes have the s...

Re-Enable CRM User
Hello Everyone, I am trying to enable a disabled CRM user and I received the following error message. Any thoughts or suggestions would be greatly appreciated. [COMException (0x80040204)] Microsoft.Crm.Platform.ComProxy.CBizUserClass.Enable(CUserAuth& Caller, String UserId) +0 Microsoft.Crm.Application.Platform.SystemUser.Activate(String id) +38 Microsoft.Crm.Web.BusinessManagement.SystemUserDetailPage.changeState(Object sender, DataEventArgs e) +127 Microsoft.Crm.Application.Forms.DataEventProcessor.Raise(FormEventId eventId, FormState state, User user, String objectId,...

Access Front end with MySQL or SQL backend (multi-user)
I have a huge excel spreadsheet with many worksheets tabs that I need to convert to a data entry database. I'm considering using Access as the front end with maybe MySQL or I think SQL which is free with MS Office. The problem is 1. We can have more than 75 concurrent users 2. budget is extremely limited, so I'm looking at Access front and/or a free SQL backend Will this combination support 75+ concurrent users? and if not, does anyone have any other suggestions? Thanks! Jorge -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-conve...

Another user is creating this item #2
Hi, Another user is creating this item - error - when trying to create a new inventory item. If any body have a solution please let me know. Thanks & Regards What version of GP are you using? This was a problem in V6 but was fixed. If you are using a newer version, get everyone out of the application and release all SQL sessions and locks -- Richard L. Whaley Author / Consultant / MVP Documentation for Software Users For help learning and better using Dynamics GP,... check out our books at http://www.AccoladePublications.com "Rainu Jacob" wrote: > Hi, > &...

mailboxes are not being created when I create new AD user account
Even though I select the check box asking that a mailbox be created nothing is created. This has been an ongoing issue with our exchange server. What I have been doing is just renaming old accounts and deleting all the mail data essentially cleaning out and old mailbox to give to a new user. I have run out of old accounts. Like I said this has been an ongoing issue. When it first occurred it only happpened sometimes. But now I am not able to create a new NT account that creates a mailbox. I have tried creating an account without a mailbox then trying to go through 'exchange tasks...

Publish form to users' Personal Forms Library via script or GPO?
I've got a client who will be migrating from internally hosted Exchange 2000 (yes, you read that correctly) to externally hosted Exchange 2007 with OL2007 clients. They are also looking to use Sharepoint (WSS 3.0) for their shared contacts & calendar, which are currently in E2000 public folders - the hosting company isn't providing PFs. Normally this would be no big deal, but they've got a nice little custom form for their public contacts, which they want to keep. It's currently published to the PF itself on their existing E2k server. As we won't have access to ...

CRM Web client times out on laptop users only
We have a small office of 16. 8 of the CRM clients are laptop/notebook users. On 2 of these, the CRM web clients will time out or shut down for no apparent reason. Both of the two notebooks run Win XP, one of them has service pack 2 and the reccommended patches for CRM installed. No other users experience this. Is there a way to find out what is causing this? If it were the global timeout value for CRM web (300 seconds - 5 minutes), would't all machines have the same problem. The user usually only has Outlook and CRM open and nothing else. How best can I debug this problem? ...

Avoid users using OWA Backend?
Is there a way to block users from going to the back end server directly for Outlook Web Access in Exchange 2003, or automatically redirect them to the front end server? We have some creative users.... Can you explain in more detail what you mean or what problem it is causing to have users go directly to the BE? You do realize that a FE server simply proxies the request to the BE, right? -- Ben Winzenz Exchange MVP MessageOne "Bill Oliman" <boliman@earthlink.net> wrote in message news:uVN453HPFHA.4000@TK2MSFTNGP15.phx.gbl... > Is there a way to block users fro...

Mailbox Limits for 2 user groups
I am trying to set up mailbox limits for 2 different user groups. Managers have a certain limit for thier mailboxes Staff have another limit. Is there a way of setting this in recipient policies? FYI How to use recipient policies to control mailboxes in Exchange 2000 and Exchange 2003 http://support.microsoft.com/kb/319188 -- Best regards, Good Luck Oz Ozugurlu ____________________________ MCSE 2003 M+,S+, CCNA Http://www.msexchange911.org Http://www.consultusa.us (Blog) "Razorbeard" wrote: > I am trying to set up mailbox limits for 2 different user groups. > > M...

How to map a user local string (using OS code page) to UTF-8 and vice-versa in C or C++?
Hi How to map a user local string (using OS code page) to UTF-8 and vice-versa ? I need send strings between clients and a server (the clients can be linux or windows) and I am thinking in use UTF-8 to change text. What happens if I change a chinese text to UTF-8, send it to the server that locale is english ? Leandro Gustavo Biss Becker ...

How can I increase the quota for one user
On my mailbox store, I have setup a 1GB limit for all users. of course, every once in a while, one of my high profile users may need their quota increased. How can I go about doing that without using a third party tool.. if possible. You can overide the store limit by setting a value on the users properties page, exchange general tab, storage limts. Todd "booker@mgt" <booker@mgt@discussions.microsoft.com> wrote in message news:64ED83DD-E1CE-4AE6-96D6-B9A74EEFF01B@microsoft.com... > On my mailbox store, I have setup a 1GB limit for all users. of course, > every...

User Defined config section "You must implement a default accessor on System.Configuration.ConfigurationLockCollection because it inherits from ICollection."
""You must implement a default accessor on System.Configuration.ConfigurationLockCollection because it inherits from ICollection."" Hello All, I am having my app.config file like : <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="PredefinedClusters" type="BinaryChecker.ClusterSection,BinaryChecker"/> </configSections> <PredefinedClusters> <Cluster name="Portal"> <Environments> <Env name="a...