What is the concept behind writing a cancel operation in c++? [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
(Please note this is my first question so apologies on rule-breaking just let me know and I'll fix it)
I'm attempting to write a cancel operation for a software download application. This application will first transfer the software to the device and then install the software on it. (These are givens I'm not allowed to change).
What should the cancel operation do? When a user presses 'cancel', the application should stop transferring/installing the software immediately.
Question: Since I've never written a "cancel" function, I'm wondering what are the types of things to consider when writing the code, and what are the common bugs I should expect and how to deal with them?
Couldn't find anything in google so if you have some links that would be good reads I'd really appreciate it since I'm not looking for answers I'm just looking for guidelines/macro/concept help

It depends on your requirements, but usually in a cancel operation you will keep a stack of the operations that have been performed so that you can go back and undo them all when cancel is clicked.

Related

It is posible to restart a PCIe card through code (using C, C++ or .NET)? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have a PCIe card for communications that often gets an error while connecting and, in order to recovering it, is needed to turn off the PC and then turn on again (a restart is not valid).
Is there any way to reset a PCIe card?
It will be interesting a hardware reset (quit and return supply), but even if there is any function for software reset, I would be interested in.
Thank you.
Even if you'd consider software resets, I think it should be pretty obvious that you cannot do this in an application. Hardware is managed by the OS. What would happen if ordinary applications could power down the video card?!
So, the answer (practically speaking) is no. Your purely theoretical chance (Linux is Open Source) is not an option if you're thinking about .Net and thus Windows.

Thread Loop with Sleep() or SetTimer [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have an Win32 app that contains 13 SetTimer() calls... I have a doubt: to optimize application performance, would be better to use CreateThread (with infinite loop and Sleep) instead SetTimer? Which of the two ways to a better way and timing of actions?
Sorry for bad english, thanks in advance!
I wouldn't write a custom timer unless you have a very specific need to do so. I'd guess performance difference would be negligible for most applications. Plus you'll run into other issues I'm sure you're not currently considering, like data synchronization, communicating with your GUI thread for user interactions, etc. It's possible you could even make performance worse.
If you feel you have a specific need, state what that need is and maybe we can guide the answer.

How to code a program can detect the signal of buttons of gamepad in C++? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to explore about the signal of buttons from my gamepad, it's old but can use. And i want to code a small program that can detect and display the 'code' of these buttons when I touch to them in C++, can any body help me, I don't know where can I start ? Please !!!
To put it shortly, if you want to make a game playable in the command line, then don't. It's not meant for that kind of purpose.
I would personally suggest the SFML library. It has utilities for drawing on a window, handling events, graphics, sound, etc. and it's also pretty simple. Here is what you are (probably) looking for:
sf::Joystick class
However, if you don't want to use any external library, you will have to rely on your OS's library (e.g windows.h on windows) but that would make the code non portable, and most people hate that, since C/C++ were created specifically for that purpose. So this method is generally not suggested.

Controling the GUI with wxWidgets [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am writing this C++ application with wxWidgets.
I want to reproduce the following situation:
There must be one single mainFrame which should control the others.
Other windows should appear inside this mainFrame (like sections)
wxNotebook must not be used.
Imagine I have wxFrameMain, wxPanelA, and wxPanelB. The application should start wxFrameMain filled up with wxPanelA and after the user choses to change the view, it should get filled up with wxPanelB.
Does anyone have any tutorial or can explain how to do that?
It's really difficult to understand what does the requirement
wxNotebook must not be used
actually mean. Does this mean that the user shouldn't be able to change the pages on his own? If so, you are probably looking for wxSimplebook. If it just means that the user should be able to change pages but using UI different from wxNotebook, then perhaps one of the other book controls can be helpful.

How would you do this without a bunch of if/else statements? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I was playing GTA IV recently and I noticed an interesting feature. I was in a cab and switched to a specific station. Niko then said something about that station.
I was wondering how they might have done this. The only way I can think of is to have an if/else statement that goes through each station and sees if that's the one he is currently listening to.
Is there a better way of doing it?
Use an enum, array of places, then you can have a piece of code like:
currentStation = .. get the current station
playSound(stations[currentStation]);
They likely do this by having a station change trigger an event. Niko is set to as a listener for this type of event. His characters programmed response to this event is to playback a certain sound.