void map_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { map.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(map_DocumentCompleted); map.AllowWebBrowserDrop = false; map.WebBrowserShortcutsEnabled = false; map.ScriptErrorsSuppressed = true; map.ObjectForScripting = this; map.AllowNavigation = false; if (instance.MonoRuntime) { map.Navigating += new WebBrowserNavigatingEventHandler(map_Navigating); } WorkPool.QueueUserWorkItem(sync => { Thread.Sleep(1000); if (InvokeRequired && (!instance.MonoRuntime || IsHandleCreated)) { BeginInvoke(new MethodInvoker(() => { if (savedRegion != null) { gotoRegion(savedRegion, savedX, savedY); } else if (Active) { gotoRegion(client.Network.CurrentSim.Name, 128, 128); } } )); } } ); }
public void BlockBusyForever() { while (true) { Thread.Sleep(100); } }
private void EnsureConnectedCheck(NetworkManager.DisconnectType reason) { if (ExpectConnected && reason != NetworkManager.DisconnectType.ClientInitiated) { return; List <Simulator> sims = new List <Simulator>(); lock (Network.Simulators) { sims.AddRange(Network.Simulators); } return; ExpectConnected = false; foreach (var s in sims) { //lock (s) { if (s.Connected) { s.Disconnect(true); } } } //gridClient = new GridClient(); //Settings.USE_LLSD_LOGIN = true; new Thread(() => { Thread.Sleep(10000); Login(true); }).Start(); } }
public void FollowLoop() { while (KeepFollowing) { Thread.Sleep(100); Vector3 lastKnown; if (!Target.TryGetSimPosition(out lastKnown)) { DLRConsole.DebugWriteLine("" + this + " Not regions attached " + Target); Thread.Sleep(2000); continue; } double dist = TheBot.Distance(Target); if (dist < maxDistance || CloseEnough()) { continue; } if (!TheCBot.SalientGoto(Target)) { SwitchSalientProc(); continue; } if (!TheCBot.WaitUntilPosSimple(Target.GlobalPosition, Target.GetSizeDistance(), 3, true)) { SwitchSalientProc(); } else { SucceedSalientProc(); } } }
public void reportError(String error) { // Error reporting is left up to you; this is a case apart // (besides, my implementation was too specific to post here) Console.WriteLine("ERR CRON : {0}", error); Thread.Sleep(5000); }
private void EnsureLoginToQIPD() { if (RK_listener != null) { return; } var uri = RoboKindEventModule.RK_QPID_URI; try { LoginToQPID(uri); } catch (Exception e) { System.Diagnostics.Process proc = new System.Diagnostics.Process(); // Declare New Process proc.StartInfo.FileName = @"QPIDServer\StartQPID.bat"; proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized; proc.StartInfo.CreateNoWindow = false; proc.StartInfo.ErrorDialog = true; //proc.StartInfo.Domain = AppDomain.CurrentDomain.Id; proc.Start(); Thread.Sleep(10000); LoginToQPID(uri); } }
public void Aging() { BotNeeds CurrentNeeds = this.CurrentNeeds; // Initially randomize foreach (FieldInfo c in CurrentNeeds.GetType().GetFields()) { if (c.FieldType == typeof(float)) { CurrentNeeds.SetValue(c, CurrentNeeds, MyRandom.Next(100)); } } BotNeeds OneMinute = SimTypeSystem.GetObjectType("OnMinuteTimer").GetUsageActual("OnMinuteTimer"); while (true) { Actor.ScanNewObjects(2, Actor.SightRange, false); CurrentNeeds.AddFrom(OneMinute); CurrentNeeds.SetRange(0.0F, 100.0F); //SimPosition to = WorldObjects.Master.m_TheSimAvatar; //if (to != null) //{ // Console.WriteLine("Aging: " + this + " " + to.DistanceVectorString(this)); //} Thread.Sleep(60000); /// one minute /// Debug(CurrentNeeds.ToString()); } }
public void Spy0() { EnsureStarted(); RK_publisher.SpyOnQueueAndTopic("#", ExchangeNameDefaults.DIRECT, "", GotMessage); RK_publisher.SpyOnQueueAndTopic("", ExchangeNameDefaults.DIRECT, "#", GotMessage); //RK_publisher.SpyOnQueueAndTopic("visionproc0", GotMessage); //RK_publisher.SpyOnQueueAndTopic("camera0", GotMessage); //RK_publisher.SpyOnQueueAndTopic("speech", GotMessage); // matters! // SpyQueue("speechRequest"); // matters? //SpyQueue("speechEvent"); // matters? // SpyQueue("speechCommand"); // matters? // SpyQueue("camera0Request"); SpyQueue("camera0Event"); SpyQueue("visionproc0Event"); SpyQueue("faceEmotion0Event"); // will crash capture SpyQueue("camera0Command"); // consumer.Receive(); // sapiserver //SpyQueue("speechCommand"); //SpyQueue("speechRequest"); /* * // sapiclient * CreateHashSpy("speechEvent"); * * // FaceRec * CreateHashSpy("queue"); * CreateHashSpy("ping"); * CreateHashSpy("test-ping"); * CreateHashSpy("test-queue"); * SpyQueue("visionproc0Event"); * * // cammeracapture.exe * SpyQueue("camera0Command"); * * // camera display * SpyQueue("camera0Event"); * * */ Console.WriteLine("spying on AQM"); Thread.Sleep(6000); }
private void PositionThreadBody() { while (true) { posRestart.WaitOne(); Thread.Sleep(1500); UpdatePosition(Client.Self); } }
public void ClearTarget() { targetRegion = nullRegion; targetX = targetY = -5000000000d; WorkPool.QueueUserWorkItem(sync => { Thread.Sleep(500); needRepaint = true; } ); }
/* * * RK_publisher.CreateListener("speechRecEvent", ExchangeNameDefaults.DIRECT, (o) => Eveything(o, "direct")); * RK_publisher.CreateListener("#", ExchangeNameDefaults.DIRECT, (o) => Eveything(o, "#direct")); * RK_publisher.CreateListener("speechRecEvent", ExchangeNameDefaults.TOPIC, (o) => Eveything(o, "topic")); * RK_publisher.CreateListener("#", ExchangeNameDefaults.TOPIC, (o) => Eveything(o, "#topic")); * * //CreateHashSpy("speechRecEvent"); * //CreateHashSpy("animPrompt"); * //CreateHashSpy(""); * //CreateHashSpy("interpreterInstanceCheck"); * //CreateHashSpy("speechRequest"); * //CreateSpy(null, "speechRequest", "speechRequest"); * // SpyQueue("ping"); * //SpyQueue("queue"); * SpyQueue("test-ping"); * SpyQueue("test-queue"); * SpyQueue(""); * SpyQueue("speechCommand"); * * CreateSpy("speechCommand", false); * CreateSpy("speechEvent", false); * CreateSpy("interpreterInstanceCheck", false); * * //RK_publisher.CreateListener("speechRecEvent", "speechRecEvent", (o) => Eveything(o, "speechRecEvent")); * //RK_publisher.CreateListener("speechRecEvent", "", (o) => Eveything(o, "blank")); * * */ public void Spy() { EnsureStarted(); // RK_publisher.SpyOnQueueAndTopic("amq.topic", ExchangeNameDefaults.TOPIC, "faceEmotion0Event", GotMessage); RK_publisher.RKListener(RoboKindEventModule.RK_QPID_URI, "faceEmotion0Event", QPIDProcessor); RK_publisher.RKListener(RoboKindEventModule.RK_QPID_URI, "faceEmotion0Error", QPIDProcessor); Console.WriteLine("spying on AQM"); RK_publisher.Connection.Start(); Thread.Sleep(6000); }
private void InventoryBackup_FormClosing(object sender, FormClosingEventArgs e) { if (backupThread != null) { if (backupThread.IsAlive) { backupThread.Abort(); Thread.Sleep(1000); } backupThread = null; } }
/// <summary> /// Shut down the background thread. /// </summary> internal override void Shutdown() { // If the background thread is alive, send it the special // empty utterance that will make it shut down gracefully. if (speakingThread != null && speakingThread.IsAlive) { Say(null, null, new Vector3(0, 0, 0), null); Thread.Sleep(600); } speakingThread = null; // Shut down the synthesizer. syn.Shutdown(); }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { float time; if (cmdArgs.Length == 0 || !float.TryParse(cmdArgs[0], out time)) { WriteLine(Usage); } else { WriteLine("pausing for " + time); Thread.Sleep((int)(time * 1000)); WriteLine("paused for " + time); } }
public void Run() { while (_run) { Thread.Sleep(_heartbeatMillis); if (!_run) { break; } _log.Debug("Sending heartbeat"); // TODO: Can we optimise this so that heartbeats are only written when we haven't sent anything recently to the broker? _protocolWriter.Write(HeartbeatBody.FRAME); } _log.Debug("Heatbeat thread stopped"); }
static void testRDFServer() { Console.WriteLine("starting testRDFServer"); PFEndpoint myServer = new PFEndpoint(); var rdfGraph = prologEngine.getRefreshedRDFGraph("spindleMT"); StringParser.Parse(rdfGraph, "<http://example.org/a1> <http://example.org/b1> <http://example.org/c1> ."); prologEngine.connectMT("spindleMT", "rdfMT"); prologEngine.appendKB("triple(this,can,work).\n", "rdfMT"); myServer.beginService(prologEngine); while (true) { Thread.Sleep(1000); } }
public override CmdResult ExecuteRequest(CmdRequest args) { if (args.Length < 1) { return(ShowUsage()); } string cmd = args.GetString("command"); //return ClientManager.DoCommandAll() // Make an immutable copy of the Clients dictionary to safely iterate over int[] completed = { 0 }; var BotClients = ClientManager.BotClients; int count = BotClients.Count; var fromAgentID = args.CallerAgent; if (count == 0) { return(ClientManager.ExecuteSystemCommand(cmd, fromAgentID, WriteLine, args.CmdFlags)); } CmdResult[] results = new CmdResult[count]; int[] clientNum = { 0 }; foreach (BotClient client in BotClients) { clientNum[0]++; ThreadPool.QueueUserWorkItem( (WaitCallback) delegate(object state) { BotClient testClient = (BotClient)state; results[clientNum[0]] = testClient.ExecuteCommand(cmd, fromAgentID, WriteLine, args.CmdFlags); ++completed[0]; }, client); } while (completed[0] < count) { Thread.Sleep(50); } foreach (var r in results) { if (r != null) { return(r); } } return(results[0]); }
public void Think() { while (true) { try { Thread.Sleep(3000); if (!IsAvatarActive()) { ThinkOnce(); } } catch (Exception e) { Debug(e.ToString()); } } }
void EnterMyLockSpin() { for (int i = 0; ; i++) { if (i < 3 && smp) { Thread.SpinWait(20); // Wait a few dozen instructions to let another processor release lock. } else { Thread.Sleep(0); // Give up my quantum. } if (Interlocked.CompareExchange(ref myLock, 1, 0) == 0) { return; } } }
public void Aging() { BotNeeds OneMinute = SimTypeSystem.GetObjectType("OnMinuteTimer").GetUsageActual("OnMinuteTimer"); while (true) { Actor.ScanNewObjects(2, Actor.SightRange, false); CurrentNeeds.AddFrom(OneMinute); CurrentNeeds.SetRange(0.0F, 100.0F); //SimPosition to = WorldObjects.Master.m_TheSimAvatar; //if (to != null) //{ // Console.WriteLine("Aging: " + this + " " + to.DistanceVectorString(this)); //} Thread.Sleep(60000); /// one minute /// Debug(CurrentNeeds.ToString()); } }
/// <summary> /// /// </summary> /// <param name="blocking"></param> /// <returns></returns> public string ReadLine(bool blocking) { string data = ""; if (blocking) { // block till the queue has data, but bail out on connection error while (IsConnected && !IsConnectionError && _ReadThread.Queue.Count == 0) { Thread.Sleep(10); } } if (IsConnected && _ReadThread.Queue.Count > 0) { data = (string)(_ReadThread.Queue.Dequeue()); } if (data != null && data.Length > 0) { #if LOG4NET Logger.Queue.Debug("read: \"" + data + "\""); #endif if (OnReadLine != null) { OnReadLine(this, new ReadLineEventArgs(data)); } } if (IsConnectionError && !IsDisconnecting && OnConnectionError != null) { OnConnectionError(this, EventArgs.Empty); } return(data); }
public void jobManager() { while (taskInterperter != null) { while (taskQueue.Count > 0) { try { taskTick(); } catch (Exception e) { DLRConsole.DebugWriteLine("!Exception: " + e.GetBaseException().Message); DLRConsole.DebugWriteLine("error occured: " + e.Message); DLRConsole.DebugWriteLine(" Stack: " + e.StackTrace.ToString()); } Thread.Sleep(5); } Thread.Sleep(500); } }
private void LoopAnim() { try { ClientSelf.AnimationStop(AssetID, true); ClientSelf.AnimationStart(AssetID, true); while (NeedsLooping) { // some anims will only last a short time so we have to // remind the server we still want to be using it // like Laugh .. lasts for about .9 seconds //12000 is a estimate average Thread.Sleep((int)(asset.Length * 1000)); ClientSelf.AnimationStop(AssetID, true); ClientSelf.AnimationStart(AssetID, true); } } catch (Exception) { } // for the Abort }
private void _Worker() { #if LOG4NET Logger.Socket.Debug("WriteThread started"); #endif try { try { while (_Connection.IsConnected) { _CheckBuffer(); Thread.Sleep(_Connection._SendDelay); } } catch (IOException e) { #if LOG4NET Logger.Socket.Warn("IOException: " + e.Message); #endif } finally { #if LOG4NET Logger.Socket.Warn("connection lost"); #endif // only flag this as connection error if we are not // cleanly disconnecting if (!_Connection.IsDisconnecting) { _Connection.IsConnectionError = true; } } } catch (ThreadAbortException) { Thread.ResetAbort(); #if LOG4NET Logger.Socket.Debug("WriteThread aborted"); #endif } catch (Exception ex) { #if LOG4NET Logger.Socket.Error(ex); #endif } }
public void TalkTo(SimObject avatar, String talkAbout) { //SimAvatar avatarWasInDialogWith = ((SimAvatarImpl) avatar).InDialogWith; //SimAvatar wasInDialogWith = InDialogWith; //try { SimObject InDialogWith = avatar; var Client = GetGridClient(); AgentManager ClientSelf = Client.Self; AgentManager.AgentMovement ClientMovement = ClientSelf.Movement; TurnToward(InDialogWith); ClientSelf.AnimationStop(Animations.TALK, true); ClientSelf.AnimationStart(Animations.TALK, true); GetBotClient().Talk(InDialogWith + ": " + talkAbout); Thread.Sleep(3000); ClientSelf.AnimationStop(Animations.TALK, true); } //finally //{ // InDialogWith = wasInDialogWith; // //avatar.InDialogWith = avatarWasInDialogWith; //} }
public void FollowLoop() { try { while (KeepFollowing) { if (!Target.IsRegionAttached) { EndFlyto(); DLRConsole.DebugWriteLine("" + this + " Not regions attached " + Target); Thread.Sleep(2000); return; } //DoZ = !DoZ; //if (DoZ) SetMovement(); FlyToOnce(); } } finally { EndFlyto(); } }
private SourceLanguage GetSyntaxType() { SourceLanguage syntaxType = SourceLanguage.Unknown; lock (tcpStreamReader) while (syntaxType == SourceLanguage.Unknown && tcpStreamReader != null) { int peeked = tcpStreamReader.Peek(); if (peeked == -1) { // probe peekchar System.Windows.Forms.Application.DoEvents(); Thread.Sleep(200); // PushbackReader r; continue; } char ch = (char)peeked; if (Char.IsWhiteSpace(ch)) { peeked = tcpStreamReader.Read(); continue; } if (ch == '(') { syntaxType = SourceLanguage.Lisp; break; } if (ch == '<') { syntaxType = SourceLanguage.Xml; break; } syntaxType = SourceLanguage.Text; } return(syntaxType); }
public bool FlyToOnce() { // startTime = 10000; try { var Client = GetGridClient(); double dist = ((SimMover)TheBot).Distance(Target); Vector3d premoved = TheBot.GlobalPosition; if (dist > maxDistance) { //ClientMovement.Fly = true; //KeepFollowing = true; //ClientMovement.AtPos = true; //startTime = 10000; if (DoZ) { Client.Self.Movement.AtPos = false; //if (startTime + 30000 > Environment.TickCount) { DoZ = false; XYMovement(); target0.X = (float)target.X; target0.Y = (float)target.Y; //Client.Objects.OnObjectUpdated -= callback; RegCallback(); SetMovement(); } } else { if (startTime.AddMinutes(1) > DateTime.Now) { DoZ = true; } } Thread.Sleep(2000); double premovedDist = Vector3d.Distance(premoved, TheBot.GlobalPosition); if (premovedDist < 1) { blockedTimes++; if (blockedTimes < 5) { return(true); } blockedTimes = 0; KeepFollowing = false; TheBot.Debug("Blocked only moved " + premovedDist); return(false); } //DoZ = !DoZ; //if (DoZ) ZMovement(); //ClientMovement.TurnToward(target); //System.Threading.Thread.Sleep(100); //if (!DoZ) XYMovement(); // ClientMovement.AtPos = false; // ClientMovement.AtNeg = false; // ZMovement(); // ClientMovement.SendUpdate(false); return(true); } else { DoZ = true; EndFlyto(); TheBot.TurnToward(Target.GlobalPosition); //Thread.Sleep(1000); // total 3 seconds return(false); } } finally { if (false) { DeRegCallback(); } } }
private void touchToolStripMenuItem_Click(object sender, EventArgs e) { Client.Self.Grab(RightclickedPrim.Prim.LocalID, Vector3.Zero, Vector3.Zero, Vector3.Zero, RightclickedFaceID, Vector3.Zero, Vector3.Zero, Vector3.Zero); Thread.Sleep(100); Client.Self.DeGrab(RightclickedPrim.Prim.LocalID, Vector3.Zero, Vector3.Zero, RightclickedFaceID, Vector3.Zero, Vector3.Zero, Vector3.Zero); }
/// <summary> /// Handle Instant Messages /// </summary> /// <param name="im"></param> /// <param name="simulator"></param> void OnInstantMessage(object sender, InstantMessageEventArgs e) { WorkPool.QueueUserWorkItem(sync => { Thread.Sleep(100); // Give tab a chance to show up IMSession sess = null; string groupName; // All sorts of things come in as a instant messages. For actual messages // we need to match them up with an existing Conversation. IM Conversations // are keyed by the name of the group or individual involved. switch (e.IM.Dialog) { case InstantMessageDialog.MessageFromAgent: if (control.instance.Groups.ContainsKey(e.IM.IMSessionID)) { // Message from a group member groupName = control.instance.Groups[e.IM.IMSessionID].Name; sess = (IMSession)control.converse.GetConversation(groupName); if (sess != null) { sess.OnMessage(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message); } else { Talker.Say(e.IM.FromAgentName + ", " + e.IM.Message); } } else if (e.IM.BinaryBucket.Length >= 2) { // Ad-hoc friend conference sess = (IMSession)control.converse.GetConversation(Utils.BytesToString(e.IM.BinaryBucket)); if (sess != null) { sess.OnMessage(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message); } else { Talker.Say(e.IM.FromAgentName + ", " + e.IM.Message); } } else if (e.IM.FromAgentName == "Second Life") { Talker.Say("Second Life says " + e.IM.Message); } else { // Message from an individual sess = (IMSession)control.converse.GetConversation(e.IM.FromAgentName); if (sess != null) { sess.OnMessage(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message); } else { Talker.Say(e.IM.FromAgentName + ", " + e.IM.Message); } } break; case InstantMessageDialog.SessionSend: if (control.instance.Groups.ContainsKey(e.IM.IMSessionID)) { // Message from a group member groupName = control.instance.Groups[e.IM.IMSessionID].Name; sess = (IMSession)control.converse.GetConversation(groupName); } else if (e.IM.BinaryBucket.Length >= 2) // ad hoc friends conference { sess = (IMSession)control.converse.GetConversation(Utils.BytesToString(e.IM.BinaryBucket)); } sess?.OnMessage(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message); break; case InstantMessageDialog.FriendshipOffered: Talker.Say(e.IM.FromAgentName + " is offering friendship."); break; default: break; } } ); }