Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8523881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:32:09+00:00 2026-06-11T07:32:09+00:00

I have a wxLua Gui app that has a Run button. Depending on selected

  • 0

I have a wxLua Gui app that has a “Run” button. Depending on selected options, Run can take a long time, so I would like to implement a “Cancel” button/feature. But it looks like everything in wxLua is working on one Gui thread, and once you hit Run, pressing Cancel does nothing, the Run always goes to completion.

Cancel basically sets a variable to true, and the running process regularly checks that variable. But the Cancel button press event never happens while Running.

I have never used co-routines; if the Run process regularly yields to a “Cancel check” process, will the Cancel event happen then?

Or is there another way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:32:11+00:00Added an answer on June 11, 2026 at 7:32 am

    (the following assumes that by “Run” you mean a long running operation in the same process and not running an external process using wxExecute or wxProcess.)

    “Cancel” event is not triggered because by executing your Run logic you have not given a chance to the UI to handle the click event.

    To avoid blocking the UI you need to do something like this. When you click Run button create a co-routine around the function you want to run:

    coro = coroutine.create(myLongRunningFunction)
    

    Your Run event is completed at this point. Then in EVT_IDLE event you will be resuming this coroutine as long as it’s not complete. It will look something like this:

    if coro then -- only if there is a coroutine to work on
      local ok, res = coroutine.resume(coro, additional, parameters)
      -- your function either yielded or returned
      -- you may check ok to see if there was an error
      -- res can tell you how far you are in the process
      -- coro can return multiple values (just give them as parameters to yield)
      if coroutine.status(coro) == 'dead' then -- finished or stopped with error
        coro = nil
        -- do whatever you need to do knowing the process is completed
      end
    end
    

    You will probably need to request more IDLE event for as long as your process is not finished as some operating systems will not trigger IDLE events unless there is some other event triggered. Assuming your handler has event parameter, you can do event:RequestMore(true) to ask for more IDLE events (RequestMore).

    Your long-running process will need to call coroutine.yield() at the right time (not too short as you will be wasting time to switch back and forth and not too long for users to notice delays in the UI); you probably need to experiment with this, but something timer-based with 100ms or so between calls may work.

    You can check for Cancel values either in your IDLE event handler or in the long-running function as you do now. The logic I described will give your application UI a chance to process Cancel event as you expect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have an app that can use tts to read text messages. It can also
Have a really weird one here. The app has two targets, just to be
Have data that has this kind of structure. Will be in ascending order by
Have data that has this kind of structure: $input = [ { animal: 'cat',
I have an app written in Lua with wxLua. While this app is running,
have written this little class, which generates a UUID every time an object of
have anyone can tell me what syntax error on this actionscript (actionscript3.0)? var rotY:
Have a bunch of WCF REST services hosted on Azure that access a SQL
have been trying couple of hours now to make my iphone app universal. The
Have some code: using (var ctx = new testDataContext()) { var options = new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.