How to implement waiting until processing is done by a device..