void IModule.Initialize() { StructuresSelf = new Dictionary <ulong, IntelUnit>(); WorkersSelf = new Dictionary <ulong, IntelUnit>(); UnitsSelf = new Dictionary <ulong, IntelUnit>(); Handler = new CaseHandler <Case, IUnit>(); Handler.RegisterHandler(Case.WorkerDestroyed, w => RemoveWorkerFromColony(w)); }
public bool TryWaitResponse(Request req, out Response response, int wait = TIMEOUT) { Response result = null; var marker = new Task(() => { }); var action = new Action <Response>(r => { result = r; marker.RunSynchronously(); }); _handler.RegisterHandler((Response.ResponseOneofCase)req.RequestCase, action); AsyncSend(req); marker.Wait(wait); _handler.DeregisterHandler(action); response = result; return(response != null); }
public void RegisterHandler(ResponseOneofCase action, Action <Response> handler) => _handler.RegisterHandler(action, handler);