Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Doing stuffs in the background

Posted on 2000-05-13
8
Medium Priority
?
194 Views
Last Modified: 2010-04-02
I am building a game, and I would like to run a function in the background.  While the user is playing the game, the user could type the [TAB] key to access a menu list where the user could save, load, quit, etc.  Also, while the user is playing the game, I would like to play a midi file in the background (Different function).  Simply put, when the user presses the [TAB] key on his/her keyboard, the program should run a certain function.  How would I accomplish this?
0
Comment
Question by:junkyboy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2806631
What OS, compiler ar you using?
0
 

Author Comment

by:junkyboy
ID: 2806656
I'm using MS VisC++ 6.0 on a Win2k machine.
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2806690
Natural way is: using threads.
About threads you can read in you Windows doc or see
 http://sourceware.cygnus.com/pthreads-win32/ for "pthreads"
If you want, i can send you simple example of using threads (write you EMail).
 
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:junkyboy
ID: 2806716
I'm creating a console program...  Would it still work???  Also, I wanted to try to make this simple and easy to follow...
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2807044
Why not? You (psevdo)code may be as :
#include <process.h>
void Thread1 (PVOID pvoid)
{
     while (!EndOfThread())
        {
          .....
        }
     _endthread () ;
}
void Thread2 (PVOID pvoid)
{
     while (!EndOfThread())
        {
          .....
        }
     _endthread () ;
}
void Thread3 (PVOID pvoid)
{
     while (!EndOfThread())
        {
          .....
        }
     _endthread () ;
}
void main()
{
   static PARAMS params1 ;
   static PARAMS params2 ;
   static PARAMS params3 ;
   _beginthread (Thread1, 0, &params1) ;
   _beginthread (Thread2, 0, &params2) ;
   _beginthread (Thread3, 0, &params3) ;
}
0
 

Author Comment

by:junkyboy
ID: 2807079
Can you send me a sample code, and if I could work it out, I'll give you the points: korngerd@yahoo.com

Thanks
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 150 total points
ID: 2807334
I 've sent you simple example.
If you want something more serious, see
http://www.codeguru.com/misc/thread_manager.shtml
If not example, not class from codeguru don't fit you, simple reject my reply.
Alex

0
 

Author Comment

by:junkyboy
ID: 2807888
I think I could work it out somehow.  Thanks for the sample!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question