Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

Wait for another file to execute before the caller continues to execute!!

2 views (last 30 days)
Hello, I come across a difficulty when working on my project and I will appreciate if someone can help me push that botelneck away. Actually, I want a function callback midst in its file to pause and wait for another callback to provide it with data before it continues.
So that is how my code look like :
classdef user < handle
events
REPLY
REQUEST
end
methods
function obj= user
end
function AddListener(arg)
addlistener(arg,'REQEST',@(src,evnt)reply(obj,src,evnt));
addlistener(arg,'REPLY',@(src,evnt)request(obj,src,evnt));
end
function reply(obj,src,evnt)
step1
step2
notify(obj,'REPLY',eventData(sendingdata));
end
function request(obj,varargin)
step1
step2
notify(obj,'REQUEST');
for i=1:(4/0.1)
pause(0.1);
end % end for loop
step3
step4
end
end %end methods block
end %end class
the class user defines object which exchange data interactively. We create two objects
user1 = user; and user2=user; add listener to each other by
user1.AddListener(user2);
user2.AddListener(user1);
Then we start the proces by
user1.request();
instead of waiting reply-callback from user2, request from user1 run to the end.
What can i do to eleviate that issue?
thanks for your help!
Bolivar

Answers (0)

This question is closed.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!