Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Interrupts?

Interrupts?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wilche
    wrote on last edited by
    #1

    Hi everybody, I'm using a function taken from a DLL. It can be a lengthy wait for it to finish so I want to create a stop button to stop the function if the function begins to take too long. As the function is in the dll, I don't know how to stop the function. Could anyone help me in teaching me how to do this? Thanks! wilche :)

    R 1 Reply Last reply
    0
    • W wilche

      Hi everybody, I'm using a function taken from a DLL. It can be a lengthy wait for it to finish so I want to create a stop button to stop the function if the function begins to take too long. As the function is in the dll, I don't know how to stop the function. Could anyone help me in teaching me how to do this? Thanks! wilche :)

      R Offline
      R Offline
      Renjith Ramachandran
      wrote on last edited by
      #2

      You can load and excecute that function in a seperate thread and when u want to stop just terminate that thread... i think that work perfect..!! R_Renjith The True CP ian

      W 1 Reply Last reply
      0
      • R Renjith Ramachandran

        You can load and excecute that function in a seperate thread and when u want to stop just terminate that thread... i think that work perfect..!! R_Renjith The True CP ian

        W Offline
        W Offline
        wilche
        wrote on last edited by
        #3

        Thanks for your reply. Not disputing what you said but I have some questions.... If I used worker thread, for example the following code: //ThreadProc is the procedure used by worker thread int ThreadProc() { // event declarations and def event[0] = ::CreateEvent(NULL, TRUE, FALSE, NULL) // Stop/abort event[1] = ::CreateEvent(NULL, TRUE, FALSE, NULL) // Run DWORD status; while(TRUE) { status = WaitForMultipleObjects(2, event, FALSE, infinite); switch(status) { case WAIT_OBJECT_0: // Abort CloseHandle(ThreadId); return result; case WAIT_OBJECT_0+1: result = RunFunction(); break; } } return result; } In this case, wouldn't it still wait for RunFunction to finish before processing the Abort Event? If I create an UI thread using message queue, I do something similar using GetMessage say. int ThreadProc() { DWORD status; while(TRUE) { status = GetMessage(&msg, NULL, 0, 0); // Check that the message is valid...code ignored here. Assume it's ok switch(msg.message) { case abort: // Abort CloseHandle(ThreadId); return result; case run: result = RunFunction(); break; } } return result; } Would I still have the same problem? In this case, RunFunction will have to be completed before the next message will be processed. Kind regards, wilche

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups