0

I am designing an App that requires a background task to be performed (to free up the UI thread) but at points during its execution it needs to test for a users click.

Is it possible to set-up listeners in a background thread or does it need to hand control back to the UI thread?

EDIT:

I have 6 small 1 second long music files (.wav) each a different musical note. When the user runs the program, each music file will play for 1 second. After all 6 have played it will then play the same notes in a different order.

e.g (1 2 3 4 5 6) then (2 1 3 4 5 6) then (2 1 4 3 5 6 ) etc...

I would like the user to be in control of one of the notes say, the note contained in file 5, every time 5 is supposed to be played, the user clicks a button to try and play the note in time with the other notes and their music file should play and the app will carry on working through with the user pressing the button once in each set of 6 notes.

Allan Macmillan
  • 1,481
  • 3
  • 18
  • 30

2 Answers2

0

I see that you want to interrupt the on going background task upon user's click,But i think you can set up a logic where it will play the files in some order and as soon as it catches user's click it will break that sequence,play file number 5 and then start another task to play the remaining files.

kaushal trivedi
  • 3,405
  • 3
  • 29
  • 47
0

You might find this answer useful. This way, you can define your own callbacks.

Community
  • 1
  • 1
hundeva
  • 1,058
  • 14
  • 30