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

  • Home
  • SEARCH
  • 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 7584827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:01:02+00:00 2026-05-30T19:01:02+00:00

What I´m doing: Have a application with player The user press the Play button,

  • 0

What I´m doing:

  • Have a application with player
  • The user press the “Play button”, “Download the file” or “Play and Download the file”
  • It fires a thread to Download the file.

I’m developing with C++ with MFC, and the thread cannot access the internals easily. I can just pass the HI/LOWWORD.

When the thread finishes, and it come back to the main thread, how can I signal what action the thread should make?
Actually I pass in the thread construction the action, like:

Calling: StartThread(file, PLAY);

The end of the thread: pClass->SendMessage(WM_DOWNLOADVIDEOTHREADEND,(WPARAM)downloadedfile,ACTION);

And then when the application receives the DOWNLOADVIDEOTHREADEND message, it check the ACTION and do it.

But it do not look elegant, it a mess!

There some pattern for this?

There´s a better way to do this?

  • 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-05-30T19:01:04+00:00Added an answer on May 30, 2026 at 7:01 pm

    In my opinion you should split the UI part of your application with your logic part in the different modules. Let’s say that you wrote an module with a name player you have to provide an interface for the player listener such as Java’s swing do it for the buttons. After that you can catch your events everywhere independent of technology you using ( QT, MFC , VCL and so on). So you could implement the bridge, strategy or observer pattern in this case. I will give you an example with a bridge design patter:

    class Player{
    private:
      IPlayerListener* _listener;
    
    private:
      static void threadCallback( void* arg ){
         Player* player = (Player*)arg;
         //Download file here
         player._listener->downloadComplete( track );
      }
    
    public:
      Player( IPlayerListener* listener ){
        _listener = listener;
      }
    
      bool playFile( uri file ){
        //Start a new thread and do all staff needed to download the file in there.
        thread.start(threadCallback, this);
      }
    };
    

    In your interface declare all types of events which player can throw:

    class IPlayerListener{
    public:
     //...
     virtual void downloadComplete( const string& track )=0;
     //...
    };
    

    Avoid using libraries like MFC in your project, because it may generate some troubles in
    future. You could move to the other platform or make the decision to use another lib like QT for your GUI.

    Good luck.

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

Sidebar

Related Questions

i am doing one small application , wheich have login functionality, in the user
I have a winforms application that is doing the following: on each query: Db
We have a business application written for Windows mobile. It has people doing inventories.
I'm doing some performance tuning and capacity planning for a low-latency application and have
I have a WCF service application and in this app I am doing calls
I have a function thats the main bottleneck of my application, because its doing
I am doing some maintenance on a VB6 Windows application. I have a .Net
I'm doing an asp.net application with one page. In this page, I have one
Hi i am doing internal mail service application , i have the field called
I am developing a .NET (C#) application with a binary file format. The plan

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.