CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2015
    Posts
    100

    Post Abort operations in c

    I want to write a c application in such a way that I want to abort the current operation and I want to go back to the previous operation is there is any API to terminate the current operations and go back to the previous operations in c. I cannot use the abort function in c because its will terminate whole application.

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Abort operations in c

    You must program on your own everything related to interrupting your operations as well as bouncing back to previous ones. There is no such API, and cannot be expected any soon, as such API hardly makes sense or worth being implemented in general.
    Best regards,
    Igor

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Abort operations in c

    What do you mean by current and previous operation - block, function, thread ...??
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  4. #4
    Join Date
    Jan 2015
    Posts
    100

    Re: Abort operations in c

    functions and threads

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Abort operations in c

    To abort a function just use return when needed - with a specific return code if required for which the calling function can check. Note that any allocated resources (eg memory, handles etc) need to be freed/closed before returning.

    Or use c++ exceptions (try/throw/catch) - note same comment re resources applies.

    For threads, are you using c++11 threads or if using specific OS API thread functions, which ones? How are you using threads?

    How can depend upon why and what is trying to be accomplished.
    Last edited by 2kaud; March 27th, 2015 at 07:05 AM.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured