Jump to content
msd

Class with own Thread

Recommended Posts

Hello,

 

I have a class which is a representation of some API communication with a REST server and that class has methods that exchange data with the server.

Because this class has communication with REST, I can't wait for every response and I would like to add threat functionality to this class.

My idea is that when I call the create method of my class, it will start in a separate thread and the whole class will work in its own thread and every method call to this class will be async.

The response class (thread in class) informs the main thread that it contains some data and the app can use it.

 

Thanks for the tips and advices in advance...

Share this post


Link to post

You don't need to put the whole class in a thread. Just put the blocking call in the thread.

Or use a non-blocking component to do the REST communication, such as ICS.

  • Thanks 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×