示例#1
0
        public Interpreter getInterpreter()
        {
            if (interpreter == null)
            {
                jlispThread = new Thread(new ThreadStart(StartJLISP));
                jlispThread.Start();
                while (interpreter == null)
                {
                    ironTextBoxControl.Update();
                }
            }
            if (varPackage == null)
            {
                varPackage = Symbol._PACKAGE_;
            }
            LispObject pkg = varPackage.symbolValue();

            if (lastPackage != pkg)
            {
                lastPackage = pkg;
                ironTextBoxControl.Prompt = ((Package)pkg).getName() + "> ";
                //ironTextBoxControl.ConsoleTextBox
            }
            return(interpreter);
        }
示例#2
0
 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);
 }
        void BtnExportClick(object sender, EventArgs e)
        {
            Enabled             = false;
            Exporter.LogMessage = LogMessage;

            Thread t = new Thread(delegate()
            {
                try
                {
                    Exporter.ExportToFile(txtFileName.Text, uLocalID);
                    LogMessage("Export Successful.");
                    if (InvokeRequired)
                    {
                        BeginInvoke(new MethodInvoker(() => Enabled = true));
                    }
                }
                catch (Exception ex)
                {
                    LogMessage("Export failed.  Reason: {0}", ex.Message);
                }
            })
            {
                IsBackground = true
            };

            t.Start();
        }
示例#4
0
 public WorldPathSystem(GridClient gc)
 {
     MeshingQueue.StackerThread.Priority = System.Threading.ThreadPriority.AboveNormal;
     lock (GlobalRoutes)
     {
         if ((!gc.Settings.AVATAR_TRACKING))
         {
             Error("client.Settings.AVATAR_TRACKING != true");
         }
         if ((!gc.Settings.ALWAYS_DECODE_OBJECTS))
         {
             Error("client.Settings.ALWAYS_DECODE_OBJECTS != true");
         }
         if ((!gc.Settings.OBJECT_TRACKING))
         {
             Error("client.Settings.OBJECT_TRACKING != true");
         }
         if (TrackPathsThread == null)
         {
             TrackPathsThread      = new Thread(TrackPaths);
             TrackPathsThread.Name = "Track paths";
             //TrackPathsThread.Priority = ThreadPriority.AboveNormal;
             TrackPathsThread.Start();
         }
     }
 }
 /// <summary>
 ///
 /// </summary>
 public void Start()
 {
     _Thread              = new Thread(new ThreadStart(_Worker));
     _Thread.Name         = "ReadThread (" + _Connection.Address + ":" + _Connection.Port + ")";
     _Thread.IsBackground = true;
     _Thread.Start();
 }
示例#6
0
 private void ExecuteCommand(string text)
 {
     lock (ExecuteCommandLock)
     {
         if (TodoThread != null)
         {
             TodoThread.Abort();
             TodoThread = null;
         }
         AIMLPadEditor edit = this;
         submitButton.Enabled = false;
         TodoThread           = new Thread(() =>
         {
             robot.AcceptInput(WriteLine, text, user, true,
                               RequestKind.CommandAndChatProcessor, true);
             if (InvokeRequired)
             {
                 Invoke(new ThreadStart(() =>
                 {
                     edit.PopulateRobotChange();
                     edit.PopulateUserChange();
                     submitButton.Enabled = true;
                     consoleInputText.SelectAll();
                 }));
             }
         });
         TodoThread.Start();
     }
 }
示例#7
0
        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);
                        }
                    }
                                                  ));
                }
            }
                                       );
        }
示例#8
0
        public MediaManager(METAboltInstance instance)
            : base()
        {
            this.Instance = instance;
            manager       = this;

            if (MainProgram.CommandLine.DisableSound)
            {
                soundSystemAvailable = false;
                return;
            }

            endCallback = new FMOD.CHANNEL_CALLBACK(DispatchEndCallback);
            allBuffers  = new Dictionary <UUID, BufferSound>();

            // Start the background thread that does all the FMOD calls.
            soundThread = new Thread(new ThreadStart(CommandLoop));
            soundThread.IsBackground = true;
            soundThread.Name         = "SoundThread";
            soundThread.Start();

            // Start the background thread that updates listerner position.
            listenerThread = new Thread(new ThreadStart(ListenerUpdate));
            listenerThread.IsBackground = true;
            listenerThread.Name         = "ListenerThread";
            listenerThread.Start();

            Instance.ClientChanged += new EventHandler <ClientChangedEventArgs>(Instance_ClientChanged);

            // Wait for init to complete
            initDone.WaitOne();
            initDone = null;
        }
示例#9
0
        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());
            }
        }
示例#10
0
        public static void ImportFromFile(GridClient client)
        {
            WindowWrapper mainWindow = new WindowWrapper(frmMain.ActiveForm.Handle);

            System.Windows.Forms.OpenFileDialog dlg = new OpenFileDialog();
            dlg.Title       = "Open object file";
            dlg.Filter      = "XML file (*.xml)|*.xml";
            dlg.Multiselect = false;
            DialogResult res = dlg.ShowDialog();

            if (res == DialogResult.OK)
            {
                Thread t = new Thread(new System.Threading.ThreadStart(delegate()
                {
                    try
                    {
                        PrimDeserializer d = new PrimDeserializer(client);
                        string primsXmls   = System.IO.File.ReadAllText(dlg.FileName);
                        d.CreateObjectFromXml(primsXmls);
                        d.CleanUp();
                        d = null;
                        MessageBox.Show(mainWindow, "Successfully imported " + dlg.FileName, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception excp)
                    {
                        MessageBox.Show(mainWindow, excp.Message, "Saving failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }));

                t.IsBackground = true;
                t.Start();
            }
        }
示例#11
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            WindowWrapper mainWindow = new WindowWrapper(frmMain.ActiveForm.Handle);

            System.Windows.Forms.SaveFileDialog dlg = new SaveFileDialog();
            dlg.AddExtension     = true;
            dlg.RestoreDirectory = true;
            dlg.Title            = "Save object as...";
            dlg.Filter           = "XML file (*.xml)|*.xml";
            DialogResult res = dlg.ShowDialog();

            if (res == DialogResult.OK)
            {
                Thread t = new Thread(new ThreadStart(delegate()
                {
                    try
                    {
                        PrimSerializer s = new PrimSerializer(client);
                        string primsXmls = s.GetSerializedPrims(client.Network.CurrentSim, selectedPrim.LocalID);
                        System.IO.File.WriteAllText(dlg.FileName, primsXmls);
                        s.CleanUp();
                        s = null;
                        MessageBox.Show(mainWindow, "Successfully saved " + dlg.FileName, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception excp)
                    {
                        MessageBox.Show(mainWindow, excp.Message, "Saving failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }));
                t.IsBackground = true;
                t.Start();
            }
        }
示例#12
0
 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();
            }
        }
 //    TcpClient tcp_client = null;
 private void tcpSrv()
 {
     try
     {
         while (!IsDisposing)
         {
             try
             {
                 {
                     TcpClient ClientHandle = tcp_socket.AcceptTcpClient();
                     var       clt          = new SingleBotTcpClient(ClientHandle, this);
                     singleBotTcpClients.Add(clt);
                     Thread t = new Thread(new ThreadStart(clt.DoLoop));
                     t.Name = "ClientHandle thread for " + ClientHandle + " " + ToString();
                     t.Start();
                 }
             }
             catch (Exception e)
             {
                 WriteLine(e.ToString());
             }
         }
         //  tcp_socket.Stop();
         // thrSvr.Abort();
     }
     catch (Exception ee)
     {
         WriteLine(ee.ToString());
     }
 }
示例#15
0
        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();
                }
            }
        }
示例#16
0
        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);
            }
        }
示例#17
0
        public void RunClientManagerStartupLisp()
        {
            if (ClientManager.StartedUpLisp)
            {
                return;
            }
            ThreadStart mi = () =>
            {
                DLRConsole.SafelyRun(clientManager.StartUpLisp);
            };

            StartUpLispThread            = Thread.CurrentThread;
            clientManager.outputDelegate = WriteLine;
            DLRConsole.DebugWriteLine("Current Thread = " + Thread.CurrentThread.Name);
            if (false && StartUpLispThread.ApartmentState == ApartmentState.STA)
            {
                mi();
            }
            else
            {
                StartUpLispThread = new Thread(mi)
                {
                    Name = "StartUpLispThread"
                };
                StartUpLispThread.SetApartmentState(ApartmentState.STA);
                StartUpLispThread.Start();
            }
        }
        ///Configuration config;

        public void startSocketListener()
        {
            // The thread that accepts the Client and awaits messages

            int maxRebinds = 10;

            this.Bound = TryBind(ServerPort);
            while (maxRebinds > 0 && !this.Bound)
            {
                ServerPort = ServerPort + ServerPortIncr;
                this.Bound = TryBind(ServerPort);
                maxRebinds--;
            }
            if (!Bound)
            {
                WriteLine("Gave up on TCPServer");
                return;
            }
            else
            {
                WriteLine("Realy bound " + ServerPort + "!");
            }
            thrSvr      = new Thread(tcpSrv);
            thrSvr.Name = ToString();
            // The thread calls the tcpSvr() method=
            thrSvr.Start();
        }
示例#19
0
        /// <summary>
        /// Initialize the synthesis subsystem.
        /// </summary>
        internal override void Start()
        {
            if (syn == null)
            {
                return;
            }

            // Fire up the synth subsystem.
            syn.Start();

            // Get the list of installed voices.  This is done in a
            // platform-specific way.
            voices.Populate(syn.GetVoices());
            voices.Start();

            // Create the work queue if we can deal with it
            if (control.osLayer != null)
            {
                queue = new Queue <QueuedSpeech>();

                // Start the background thread that does all the text-to-speech.
                speakingThread = new Thread(new ThreadStart(SpeakLoop));
                speakingThread.IsBackground = true;
                speakingThread.Name         = "SpeakingThread";
                speakingThread.Start();
            }
        }
示例#20
0
 public void Dispose()
 {
     lock (CommandsLoaded)
     {
         CommandsLoaded.ForEach(plug =>
         {
             try
             {
                 plug.Dispose();
             }
             catch (Exception) { }
         });
         CommandsLoaded.Clear();
     }
     lock (InterpretersLoaded)
     {
         InterpretersLoaded.ForEach(plug =>
         {
             try
             {
                 plug.Dispose();
             }
             catch (Exception) { }
         });
         InterpretersLoaded.Clear();
     }
     CommandsByName.Clear();
     _commandWorker.Abort();
     _commandWorker = null;
     CommandQueued  = null;
 }
示例#21
0
        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);
        }
示例#22
0
 public void Start()
 {
     assetLoop = new Thread(LoopAnim)
     {
         Name = string.Format("Thread for {0}", ToString())
     };
     assetLoop.Start();
 }
 public void ExitUpgradeableReadLock()
 {
     EnterMyLock();
     Debug.Assert(owners > 0, "Releasing an upgradable lock, but there was no reader!");
     --owners;
     upgradable_thread = null;
     ExitAndWakeUpAppropriateWaiters();
 }
 public void StartHeartBeatThread(int heartbeatSeconds)
 {
     _log.Debug("Starting new heartbeat thread");
     _heartBeatRunner      = new HeartBeatThread(ProtocolWriter, heartbeatSeconds * 1000);
     _heartBeatThread      = new Thread(new ThreadStart(_heartBeatRunner.Run));
     _heartBeatThread.Name = "HeartBeat";
     _heartBeatThread.Start();
 }
示例#25
0
        internal void KillIt()
        {
            Thread w = WorkerThread;

            if (w != null && w.IsAlive)
            {
                w.Abort();
            }
        }
示例#26
0
 private void PositionThreadBody()
 {
     while (true)
     {
         posRestart.WaitOne();
         Thread.Sleep(1500);
         UpdatePosition(Client.Self);
     }
 }
示例#27
0
 public FollowerAction(SimAvatar impl, SimPosition position)
     : base(impl, position)
 {
     TheBot            = (SimControllableAvatar)impl;
     maxDistance       = 3;// position.GetSizeDistance();
     Target            = position;
     FollowThread      = new Thread(FollowLoop);
     FollowThread.Name = DebugName;
 }
示例#28
0
 public FollowerAction(SimAvatar impl, SimPosition position)
     : base(impl,position)
 {
     TheBot = (SimControllableAvatar)impl; 
     maxDistance = 3;// position.GetSizeDistance();
     Target = position;
     FollowThread = new Thread(FollowLoop);
     FollowThread.Name = DebugName;
 }
 public void ReloadInventory()
 {
     Inventory.Items                = new Dictionary <UUID, InventoryNode>();
     Inventory.RootFolder           = Inventory.RootFolder;
     Inventory.RootNode.NeedsUpdate = true;
     InventoryUpdate                = new Thread(new ThreadStart(StartTraverseNodes));
     InventoryUpdate.Name           = "InventoryUpdate";
     InventoryUpdate.IsBackground   = true;
     InventoryUpdate.Start();
 }
示例#30
0
        private void StartFailoverThread()
        {
            Thread failoverThread = new Thread(new ThreadStart(_failoverHandler.Run));

            failoverThread.Name = "Failover";
            // Do not inherit daemon-ness from current thread as this can be a daemon
            // thread such as a AnonymousIoService thread.
            failoverThread.IsBackground = false;
            failoverThread.Start();
        }
        //
        // Taking the Upgradable read lock is like taking a read lock
        // but we limit it to a single upgradable at a time.
        //
        public bool TryEnterUpgradeableReadLock(int millisecondsTimeout)
        {
            if (millisecondsTimeout < Timeout.Infinite)
            {
                throw new ArgumentOutOfRangeException("millisecondsTimeout");
            }

            if (read_locks == null)
            {
                throw new ObjectDisposedException(null);
            }

            if (IsUpgradeableReadLockHeld)
            {
                throw new LockRecursionException();
            }

            if (IsWriteLockHeld)
            {
                throw new LockRecursionException();
            }

            EnterMyLock();
            while (true)
            {
                if (owners == 0 && numWriteWaiters == 0 && upgradable_thread == null)
                {
                    owners++;
                    upgradable_thread = Thread.CurrentThread;
                    break;
                }

                // If the request is to probe
                if (millisecondsTimeout == 0)
                {
                    ExitMyLock();
                    return(false);
                }

                if (readEvent == null)
                {
                    LazyCreateEvent(ref readEvent, false);
                    // since we left the lock, start over.
                    continue;
                }

                if (!WaitOnEvent(readEvent, ref numReadWaiters, millisecondsTimeout))
                {
                    return(false);
                }
            }

            ExitMyLock();
            return(true);
        }
示例#32
0
        public ScriptEventListener(ScriptInterpreter interp, BotClient client)
        {
            taskInterperter = interp;
            taskInterperter.Intern("Client", client);
            taskInterperter.Intern("thisClient", client);
            if (client != null) WorldSystem = client.WorldSystem;

            thrJobQueue = new Thread(jobManager);
            thrJobQueue.Name = string.Format("ScriptEventListener Thread for {0}", (client ?? (Object)"ClientManager"));
            thrJobQueue.Start();
        }
示例#33
0
 public WorldPathSystem(GridClient gc)
 {
     MeshingQueue.StackerThread.Priority = System.Threading.ThreadPriority.AboveNormal;
     lock (GlobalRoutes)
     {
         if ((!gc.Settings.AVATAR_TRACKING)) Error("client.Settings.AVATAR_TRACKING != true");
         if ((!gc.Settings.ALWAYS_DECODE_OBJECTS)) Error("client.Settings.ALWAYS_DECODE_OBJECTS != true");
         if ((!gc.Settings.OBJECT_TRACKING)) Error("client.Settings.OBJECT_TRACKING != true");
         if (TrackPathsThread == null)
         {
             TrackPathsThread = new Thread(TrackPaths);
             TrackPathsThread.Name = "Track paths";
             //TrackPathsThread.Priority = ThreadPriority.AboveNormal;
             TrackPathsThread.Start();
         }
     }
 }
示例#34
0
 private void InventoryBackup_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (backupThread != null)
     {
         if (backupThread.IsAlive)
         {
             backupThread.Abort();
             Thread.Sleep(1000);
         }
         backupThread = null;
     }
 }
示例#35
0
        public void Init2()
        {
            if (instance.MainForm.InvokeRequired)
            {
                instance.MainForm.BeginInvoke(new MethodInvoker(() => Init2()));
                return;
            }

            AddFolderFromStore(invRootNode, Inventory.RootFolder);

            sorter = new InvNodeSorter();

            if (!instance.GlobalSettings.ContainsKey("inv_sort_bydate"))
                instance.GlobalSettings["inv_sort_bydate"] = OSD.FromBoolean(true);
            if (!instance.GlobalSettings.ContainsKey("inv_sort_sysfirst"))
                instance.GlobalSettings["inv_sort_sysfirst"] = OSD.FromBoolean(true);

            sorter.ByDate = instance.GlobalSettings["inv_sort_bydate"].AsBoolean();
            sorter.SystemFoldersFirst = instance.GlobalSettings["inv_sort_sysfirst"].AsBoolean();

            tbtnSortByDate.Checked = sorter.ByDate;
            tbtbSortByName.Checked = !sorter.ByDate;
            tbtnSystemFoldersFirst.Checked = sorter.SystemFoldersFirst;

            invTree.TreeViewNodeSorter = sorter;

            if (instance.MonoRuntime)
            {
                invTree.BackColor = Color.FromKnownColor(KnownColor.Window);
                invTree.ForeColor = invTree.LineColor = Color.FromKnownColor(KnownColor.WindowText);
                InventoryFolder f = new InventoryFolder(UUID.Random());
                f.Name = "";
                f.ParentUUID = UUID.Zero;
                f.PreferredType = AssetType.Unknown;
                TreeNode dirNode = new TreeNode();
                dirNode.Name = f.UUID.ToString();
                dirNode.Text = f.Name;
                dirNode.Tag = f;
                dirNode.ImageIndex = GetDirImageIndex(f.PreferredType.ToString().ToLower());
                dirNode.SelectedImageIndex = dirNode.ImageIndex;
                invTree.Nodes.Add(dirNode);
                invTree.Sort();
            }

            saveAllTToolStripMenuItem.Enabled = false;
            InventoryUpdate = new Thread(new ThreadStart(StartTraverseNodes));
            InventoryUpdate.Name = "InventoryUpdate";
            InventoryUpdate.IsBackground = true;
            InventoryUpdate.Start();

            invRootNode.Expand();

            invTree.AfterExpand += new TreeViewEventHandler(TreeView_AfterExpand);
            invTree.NodeMouseClick += new TreeNodeMouseClickEventHandler(invTree_MouseClick);
            invTree.NodeMouseDoubleClick += new TreeNodeMouseClickEventHandler(invTree_NodeMouseDoubleClick);

            _EditTimer = new System.Threading.Timer(OnLabelEditTimer, null, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);

            // Callbacks
            Inventory.InventoryObjectAdded += new EventHandler<InventoryObjectAddedEventArgs>(Inventory_InventoryObjectAdded);
            Inventory.InventoryObjectUpdated += new EventHandler<InventoryObjectUpdatedEventArgs>(Inventory_InventoryObjectUpdated);
            Inventory.InventoryObjectRemoved += new EventHandler<InventoryObjectRemovedEventArgs>(Inventory_InventoryObjectRemoved);

            client.Objects.ObjectUpdate += new EventHandler<PrimEventArgs>(Objects_AttachmentUpdate);
            client.Objects.KillObject += new EventHandler<KillObjectEventArgs>(Objects_KillObject);
            client.Appearance.AppearanceSet += new EventHandler<AppearanceSetEventArgs>(Appearance_AppearanceSet);
        }
示例#36
0
        //    TcpClient tcp_client = null;
        private void tcpSrv()
        {

            try
            {
                while (!IsDisposing)
                {
                    try
                    {

                        {
                            TcpClient ClientHandle = tcp_socket.AcceptTcpClient();
                            var clt = new SingleBotTcpClient(ClientHandle, this);
                            singleBotTcpClients.Add(clt);
                            Thread t = new Thread(new ThreadStart(clt.DoLoop));
                            t.Name = "ClientHandle thread for " + ClientHandle + " " + ToString();
                            t.Start();

                        }
                    }
                    catch (Exception e)
                    {
                        WriteLine(e.ToString());
                    }
                }
                //  tcp_socket.Stop();
                // thrSvr.Abort();

            }
            catch (Exception ee)
            {
                WriteLine(ee.ToString());
            }
        }
示例#37
0
        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (statusTimer != null)
            {
                statusTimer.Stop();
                statusTimer.Dispose();
                statusTimer = null;
            }

            if (mediaConsole != null)
            {
                if (tabsConsole.TabExists("media"))
                {
                    tabsConsole.Tabs["media"].AllowClose = true;
                    tabsConsole.Tabs["media"].Close();
                }
                else
                {
                    mediaConsole.Dispose();
                }
                mediaConsole = null;
            }

            if (netcom.IsLoggedIn)
            {
                Thread saveInvToDisk = new Thread(new ThreadStart(
                    delegate()
                    {
                        client.Inventory.Store.SaveToDisk(instance.InventoryCacheFileName);
                    }));
                saveInvToDisk.Name = "Save inventory to disk";
                saveInvToDisk.Start();

                netcom.Logout();
            }
        }
示例#38
0
 public CommandsManager(RadegastInstance inst)
 {
     instance = inst;
     AddCmd("help", "Shows help info", "help help",
            (name, cmdargs, writeline) =>
            {
                string args = String.Join(" ", cmdargs);
                Help(args, writeline);
                lock (InterpretersLoaded) foreach (ICommandInterpreter manager in InterpretersLoaded)
                    {
                        manager.Help(args, writeline);
                    }
            });
     _commandWorker = new Thread(CommandsManager_CommandWorker)
                         {
                             Name = "CommandsManager Worker",
                             IsBackground = true
                         };
     _commandWorker.Start();
 }
示例#39
0
 public void DoLoop()
 {
     try
     {
         WriteLine("TCPDEBUG: Entering Do Loop");
         // Start loop and handle commands:
         AbortThread = Thread.CurrentThread;
         Server.parent.AddBotMessageSubscriber(filter);
         // NETWORK STREAM MUST BE OBTAINED FROM THIS THREAD
         networkStream = tcp_client.GetStream();
         tcpStreamWriter = new StreamWriter(networkStream);
         EventsEnabled = true;
         try
         {
             tcpStreamWriter.WriteLine("<!-- Welcome to Cogbot " + botclient.GetName() + " !-->");
             tcpStreamWriter.Flush();
         }
         catch (Exception e)
         {
             WriteError(e);
             return;
         }
         // rE sHARPER is wrong!
         // ReSharper disable ConditionIsAlwaysTrueOrFalse
         while (!quitRequested && tcpStreamWriter != null)
         // ReSharper restore ConditionIsAlwaysTrueOrFalse
         {
             try
             {
                 lock (readerSwitchLock)
                 {
                     tcpStreamReader = new StreamReader(networkStream);
                 }
             }
             catch (Exception e)
             {
                 WriteError(e);
                 return;
             }
             try
             {
                 tcpStreamWriter.Flush();
             }
             catch (Exception e)
             {
                 WriteError(e);
                 return;
             }
             try
             {
                 WriteLine("TCPDEBUG: ProcessOneCommand");
                 lock (readerSwitchLock)
                     ProcessOneCommand();
             }
             catch (Exception e)
             {
                 WriteError(e);
             }
             try
             {
                 tcpStreamWriter.Flush();
             }
             catch (Exception e)
             {
                 WriteError(e);
                 return;
             }
             continue;
         }
     }
     finally
     {
         Shutdown();
     }
 }
示例#40
0
        public NameManager(RadegastInstance instance)
        {
            this.instance = instance;

            requestTimer = new Timer(MakeRequest, null, Timeout.Infinite, Timeout.Infinite);
            cacheTimer = new Timer(SaveCache, null, Timeout.Infinite, Timeout.Infinite);
            cacheFileName = Path.Combine(instance.UserDir, "name.cache");
            LoadCachedNames();
            instance.ClientChanged += new EventHandler<ClientChangedEventArgs>(instance_ClientChanged);
            RegisterEvents(client);

            // Mono HTTPWebRequest sucks balls
            useRequestThread = instance.MonoRuntime;

            if (useRequestThread)
            {
                PendingLookups = new BlockingQueue<List<UUID>>();
                lookupGate = new Semaphore(4, 4);
                requestThread = new Thread(new ThreadStart(RequestThread));
                requestThread.IsBackground = true;
                requestThread.Name = "Display Name Request Thread";
                requestThread.Start();
            }
        }
示例#41
0
 public override void Abort()
 {
     if (avatarThinkerThread != null)
     {
         try
         {
             ///  avatarThinkerThread.Suspend();
             avatarThinkerThread.Abort();
             avatarThinkerThread = null;
         }
         catch (Exception)
         {
         }
     }
     if (IsControlling)
     {
         Actor.CurrentAction = null;
     }
 }
示例#42
0
 virtual public void OnlyMoveOnThisThread()
 {
     if (!IsControllable)
     {
         throw Error("GotoTarget !Client.Self.AgentID == Prim.ID");
     }
     if (MovementConsumer != null)
     {
         if (MovementConsumer != Thread.CurrentThread && MovementConsumer.IsAlive)
         {
             if (!MovementConsumer.IsBackground)
             {
                 Client.DisplayNotificationInChat("Aborting movement thread " + MovementConsumer);
                 MovementConsumer.Abort();
             }
         }
     }
     //throw new NotImplementedException();
     MovementConsumer = Thread.CurrentThread;
 }
示例#43
0
        private void EnsureTrackerRunning()
        {
            lock (TrackerLoopLock)
            {
                if (ApproachThread == null || !ApproachThread.IsAlive)
                {
                    WorldSystem.SetSimAvatar(this);
                    ApproachThread = new Thread(TrackerLoop);
                    ApproachThread.Name = "TrackerLoop for " + Client;
                    ApproachThread.Priority = System.Threading.ThreadPriority.Normal;
                    ApproachThread.IsBackground = true;
                    //Client.Self.Movement.UseOnlyThreads.Add(ApproachThread);
                    ApproachThread.Start();

                    Client.Network.RegisterCallback(PacketType.AlertMessage, AlertMessageHandler);
                }
            }
        }
示例#44
0
        public void Dispose()
        {
            SaveCache(new object());

            if (client != null)
            {
                DeregisterEvents(client);
            }

            if (requestTimer != null)
            {
                requestTimer.Dispose();
                requestTimer = null;
            }

            if (cacheTimer != null)
            {
                cacheTimer.Dispose();
                cacheTimer = null;
            }

            try
            {
                if (useRequestThread)
                {
                    PendingLookups.Close();
                    if (requestThread != null)
                    {
                        if (!requestThread.Join(5 * 1000))
                        {
                            requestThread.Abort();
                        }
                        requestThread = null;
                    }
                }
            }
            catch { }
        }
示例#45
0
        public static Thread InSTAThread(ThreadStart invoker, string fullName) {

            Thread t = new Thread(new ThreadStart(() =>
            {
                Thread ct = Thread.CurrentThread;
                try
                {
                    if (ct.ApartmentState != ApartmentState.STA) ct.SetApartmentState(ApartmentState.STA);
                }
                catch (Exception)
                {
                } 
                try
                {
                    invoker();
                   // ct.Abort();
                }
                catch (Exception e)
                {
                    GlobalWriteLine(fullName + " " + e);
                }
            }));
            t.Name = "InSTAThread " + fullName;
            try
            {
                if (t.ApartmentState != ApartmentState.STA) t.SetApartmentState(ApartmentState.STA);
            }
            catch (Exception)
            {
                               
            }
            t.Start();
            return t;
        }
示例#46
0
        public MediaManager(RadegastInstance instance)
            : base()
        {
            this.Instance = instance;
            manager = this;

            if (MainProgram.CommandLine.DisableSound)
            {
                soundSystemAvailable = false;
                return;
            }

            endCallback = new FMOD.CHANNEL_CALLBACK(DispatchEndCallback);
            allBuffers = new Dictionary<UUID, BufferSound>();

            // Start the background thread that does all the FMOD calls.
            soundThread = new Thread(new ThreadStart(CommandLoop));
            soundThread.IsBackground = true;
            soundThread.Name = "SoundThread";
            soundThread.Start();

            // Start the background thread that updates listerner position.
            listenerThread = new Thread(new ThreadStart(ListenerUpdate));
            listenerThread.IsBackground = true;
            listenerThread.Name = "ListenerThread";
            listenerThread.Start();

            Instance.ClientChanged += new EventHandler<ClientChangedEventArgs>(Instance_ClientChanged);

            // Wait for init to complete
            initDone.WaitOne();
            initDone = null;
        }
示例#47
0
        public void ReloadInventory()
        {
            if (TreeUpdateInProgress)
            {
                TreeUpdateTimer.Stop();
                InventoryUpdate.Abort();
                InventoryUpdate = null;
            }

            saveAllTToolStripMenuItem.Enabled = false;

            Inventory.Items = new Dictionary<UUID, InventoryNode>();
            Inventory.RootFolder = Inventory.RootFolder;

            invTree.Nodes.Clear();
            UUID2NodeCache.Clear();
            invRootNode = AddDir(null, Inventory.RootFolder);
            Inventory.RootNode.NeedsUpdate = true;

            InventoryUpdate = new Thread(new ThreadStart(StartTraverseNodes));
            InventoryUpdate.Name = "InventoryUpdate";
            InventoryUpdate.IsBackground = true;
            InventoryUpdate.Start();
            invRootNode.Expand();
        }
示例#48
0
        void DisposeInternal()
        {
            RenderingEnabled = false;
            Application.Idle -= new EventHandler(Application_Idle);
            Instance.State.CameraTracksOwnAvatar = true;
            Instance.State.SetDefaultCamera();

            if (!PendingTextures.Closed)
            {
                TextureThreadContextReady.Reset();
                TextureThreadRunning = false;
                PendingTextures.Close();
                TextureThreadContextReady.WaitOne(5000, false);
            }

            if (chatOverlay != null)
            {
                chatOverlay.Dispose();
                chatOverlay = null;
            }

            if (textRendering != null)
            {
                textRendering.Dispose();
                textRendering = null;
            }

            Client.Objects.TerseObjectUpdate -= new EventHandler<TerseObjectUpdateEventArgs>(Objects_TerseObjectUpdate);
            Client.Objects.ObjectUpdate -= new EventHandler<PrimEventArgs>(Objects_ObjectUpdate);
            Client.Objects.AvatarUpdate -= new EventHandler<AvatarUpdateEventArgs>(Objects_AvatarUpdate);
            Client.Network.UnregisterCallback(PacketType.KillObject, KillObjectHandler);
            Client.Network.SimChanged -= new EventHandler<SimChangedEventArgs>(Network_SimChanged);
            Client.Terrain.LandPatchReceived -= new EventHandler<LandPatchReceivedEventArgs>(Terrain_LandPatchReceived);
            Client.Avatars.AvatarAnimation -= new EventHandler<AvatarAnimationEventArgs>(AvatarAnimationChanged);
            Client.Avatars.AvatarAppearance -= new EventHandler<AvatarAppearanceEventArgs>(Avatars_AvatarAppearance);
            Client.Appearance.AppearanceSet -= new EventHandler<AppearanceSetEventArgs>(Appearance_AppearanceSet);

            if (!PendingTasks.Closed)
            {
                PendingTasks.Close();
            }

            if (genericTaskThread != null)
            {
                genericTaskThread.Join(2000);
                genericTaskThread = null;
            }

            if (instance.Netcom != null)
            {
                Instance.Netcom.ClientDisconnected -= new EventHandler<DisconnectedEventArgs>(Netcom_ClientDisconnected);
            }

            lock (sculptCache)
            {
                foreach (var img in sculptCache.Values)
                    img.Dispose();
                sculptCache.Clear();
            }

            lock (Prims) Prims.Clear();
            lock (Avatars) Avatars.Clear();

            TexturesPtrMap.Clear();

            if (glControl != null)
            {
                glControl_UnhookEvents();
                try
                {
                    glControl.MakeCurrent();
                }
                catch { }
                try
                {
                    glControl.Dispose();
                }
                catch { }
            }
            glControl = null;

            GC.Collect();
        }
示例#49
0
 public void StartThinking()
 {
     if (avatarThinkerThread == null)
     {
         avatarThinkerThread = new Thread(Think) { Name = String.Format("AvatarThinkerThread for {0}", ObservedActor) };
         if (ObservedActor.IsControllable)
         {
             ///  only think for ourselves
             avatarThinkerThread.Priority = ThreadPriority.Normal;
             avatarThinkerThread.Start();
         }
     }
     else if (!avatarThinkerThread.IsAlive) avatarThinkerThread.Resume();
 }
示例#50
0
        void glControl_Load(object sender, EventArgs e)
        {
            if (glControlLoaded) return;

            try
            {
                GL.ShadeModel(ShadingModel.Smooth);

                GL.Enable(EnableCap.Lighting);
                GL.Enable(EnableCap.Light0);
                SetSun();

                GL.ClearDepth(1.0d);
                GL.Enable(EnableCap.DepthTest);
                GL.Enable(EnableCap.CullFace);
                GL.CullFace(CullFaceMode.Back);

                // GL.Color() tracks objects ambient and diffuse color
                GL.Enable(EnableCap.ColorMaterial);
                GL.ColorMaterial(MaterialFace.Front, ColorMaterialParameter.AmbientAndDiffuse);

                GL.DepthMask(true);
                GL.DepthFunc(DepthFunction.Lequal);
                GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
                GL.MatrixMode(MatrixMode.Projection);

                GL.AlphaFunc(AlphaFunction.Greater, 0.5f);
                GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

                // Compatibility checks
                OpenTK.Graphics.IGraphicsContextInternal context = glControl.Context as OpenTK.Graphics.IGraphicsContextInternal;
                string glExtensions = GL.GetString(StringName.Extensions);

                // VBO
                RenderSettings.ARBVBOPresent = context.GetAddress("glGenBuffersARB") != IntPtr.Zero;
                RenderSettings.CoreVBOPresent = context.GetAddress("glGenBuffers") != IntPtr.Zero;
                RenderSettings.UseVBO = (RenderSettings.ARBVBOPresent || RenderSettings.CoreVBOPresent)
                    && instance.GlobalSettings["rendering_use_vbo"];

                // Occlusion Query
                RenderSettings.ARBQuerySupported = context.GetAddress("glGetQueryObjectivARB") != IntPtr.Zero;
                RenderSettings.CoreQuerySupported = context.GetAddress("glGetQueryObjectiv") != IntPtr.Zero;
                RenderSettings.OcclusionCullingEnabled = (RenderSettings.CoreQuerySupported || RenderSettings.ARBQuerySupported)
                    && instance.GlobalSettings["rendering_occlusion_culling_enabled2"];

                // Mipmap
                RenderSettings.HasMipmap = context.GetAddress("glGenerateMipmap") != IntPtr.Zero;

                // Shader support
                RenderSettings.HasShaders = glExtensions.Contains("vertex_shader") && glExtensions.Contains("fragment_shader");

                // Multi texture
                RenderSettings.HasMultiTexturing = context.GetAddress("glMultiTexCoord2f") != IntPtr.Zero;
                RenderSettings.WaterReflections = instance.GlobalSettings["water_reflections"];

                if (!RenderSettings.HasMultiTexturing || !RenderSettings.HasShaders)
                {
                    RenderSettings.WaterReflections = false;
                }

                // Do textures have to have dimensions that are powers of two
                RenderSettings.TextureNonPowerOfTwoSupported = glExtensions.Contains("texture_non_power_of_two");

                // Occlusion culling
                RenderSettings.OcclusionCullingEnabled = Instance.GlobalSettings["rendering_occlusion_culling_enabled2"]
                    && (RenderSettings.ARBQuerySupported || RenderSettings.CoreQuerySupported);

                // Shiny
                RenderSettings.EnableShiny = Instance.GlobalSettings["scene_viewer_shiny"];

                RenderingEnabled = true;
                // Call the resizing function which sets up the GL drawing window
                // and will also invalidate the GL control
                glControl_Resize(null, null);
                RenderingEnabled = false;

                // glControl.Context.MakeCurrent(null);
                TextureThreadContextReady.Reset();
                var textureThread = new Thread(() => TextureThread())
                {
                    IsBackground = true,
                    Name = "TextureDecodingThread"
                };
                textureThread.Start();
                TextureThreadContextReady.WaitOne(1000, false);
                // glControl.MakeCurrent();
                InitWater();
                InitShaders();
                RenderingEnabled = true;
                glControlLoaded = true;
                LoadCurrentPrims();
            }
            catch (Exception ex)
            {
                RenderingEnabled = false;
                Logger.Log("Failed to initialize OpenGL control", Helpers.LogLevel.Warning, Client, ex);
            }
        }
示例#51
0
 public void Dispose()
 {
     lock (CommandsLoaded)
     {
         CommandsLoaded.ForEach(plug =>
         {
             try
             {
                 plug.Dispose();
             }
             catch (Exception) { }
         });
         CommandsLoaded.Clear();
     }
     lock (InterpretersLoaded)
     {
         InterpretersLoaded.ForEach(plug =>
         {
             try
             {
                 plug.Dispose();
             }
             catch (Exception) { }
         });
         InterpretersLoaded.Clear();
     }
     CommandsByName.Clear();
     _commandWorker.Abort();
     _commandWorker = null;
     CommandQueued = null;
 }
示例#52
0
        public SceneWindow(RadegastInstance instance)
            : base(instance)
        {
            InitializeComponent();

            this.Instance = instance;
            this.Client = instance.Client;

            UseMultiSampling = Instance.GlobalSettings["use_multi_sampling"];

            genericTaskThread = new Thread(new ThreadStart(GenericTaskRunner));
            genericTaskThread.IsBackground = true;
            genericTaskThread.Name = "Generic task queue";
            genericTaskThread.Start();

            renderer = new MeshmerizerR();
            renderTimer = new System.Diagnostics.Stopwatch();
            renderTimer.Start();

            // Camera initial setting
            Instance.State.CameraTracksOwnAvatar = false;
            Camera = new Camera();
            InitCamera();
            SetWaterPlanes();

            chatOverlay = new ChatOverlay(instance, this);
            textRendering = new TextRendering(instance);
            terrain = new RenderTerrain(instance);

            cbChatType.SelectedIndex = 1;

            DrawDistance = Instance.GlobalSettings["draw_distance"];
            pnlDebug.Visible = Instance.GlobalSettings["scene_viewer_debug_panel"];

            Client.Objects.TerseObjectUpdate += new EventHandler<TerseObjectUpdateEventArgs>(Objects_TerseObjectUpdate);
            Client.Objects.ObjectUpdate += new EventHandler<PrimEventArgs>(Objects_ObjectUpdate);
            Client.Objects.AvatarUpdate += new EventHandler<AvatarUpdateEventArgs>(Objects_AvatarUpdate);

            Client.Network.RegisterCallback(PacketType.KillObject, KillObjectHandler);
            Client.Network.SimChanged += new EventHandler<SimChangedEventArgs>(Network_SimChanged);
            Client.Terrain.LandPatchReceived += new EventHandler<LandPatchReceivedEventArgs>(Terrain_LandPatchReceived);
            Client.Avatars.AvatarAnimation += new EventHandler<AvatarAnimationEventArgs>(AvatarAnimationChanged);
            Client.Avatars.AvatarAppearance += new EventHandler<AvatarAppearanceEventArgs>(Avatars_AvatarAppearance);
            Client.Appearance.AppearanceSet += new EventHandler<AppearanceSetEventArgs>(Appearance_AppearanceSet);
            Instance.Netcom.ClientDisconnected += new EventHandler<DisconnectedEventArgs>(Netcom_ClientDisconnected);
            Application.Idle += new EventHandler(Application_Idle);

            Radegast.GUI.GuiHelpers.ApplyGuiFixes(this);
        }
 internal void DoWork()
 {
     WorkerThread = new Thread(DoWorkNow, 0)
                        {
                            Name = "Worker for " + GetName(),
                        };
     WorkerThread.Start();
     if (!DoWorkInThread) WorkerThread.Join();
 }
示例#54
0
        void BtnUploadClick(object sender, EventArgs e)
        {
            this.Enabled = false;
            if (cmbImageOptions.SelectedIndex == -1)
            {
                MessageBox.Show("You must select an Image Option before you can import an object.","Import Object Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                this.Enabled = true;
                return;
            }
            switch(cmbImageOptions.SelectedIndex)
            {
                case 0:
                    Importer.TextureUse = PrimImporter.TextureSet.OriginalUUID;
                    break;
                case 1:
                    Importer.TextureUse = PrimImporter.TextureSet.NewUUID;
                    break;
                case 2:
                    Importer.TextureUse = PrimImporter.TextureSet.SculptUUID;
                    break;
                case 3:
                    Importer.TextureUse = PrimImporter.TextureSet.WhiteUUID;
                    break;
            }
            if (chckRezAtLoc.Checked)
            {
                float x = 0.0f;
                float y = 0.0f;
                float z = 0.0f;
                if (!float.TryParse(txtX.Text,out x))
                {
                    MessageBox.Show("X Coordinate needs to be a Float position!  Example: 1.500","Import Object Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    this.Enabled = true;
                    return;
                }
                if (!float.TryParse(txtY.Text,out y))
                {
                    MessageBox.Show("Y Coordinate needs to be a Float position!  Example: 1.500","Import Object Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    this.Enabled = true;
                    return;
                }
                if (!float.TryParse(txtZ.Text,out z))
                {
                    MessageBox.Show("Z Coordinate needs to be a Float position!  Example: 1.500","Import Object Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    this.Enabled = true;
                    return;
                }
                Importer.RezAt = new Vector3(x,y,z);
            }
            else
            {
                Importer.RezAt = Client.Self.SimPosition;
                Importer.RezAt.Z += 3.5f;
            }

            Thread t = new Thread(new System.Threading.ThreadStart(delegate()
            {
                try
                {
                    start = DateTime.Now;
                    // First upload Images that will be needed by the Importer, if required by user.
                    if (Importer.TextureUse == PrimImporter.TextureSet.NewUUID || Importer.TextureUse == PrimImporter.TextureSet.SculptUUID)
                        UploadImages();

                    // Check to see if there are any failed uploads.
                    if (FailedUploads.Count > 0)
                    {
                        DialogResult res = MessageBox.Show(String.Format("Failed to upload {0} textures, which to try again?",FailedUploads.Count),
                                                           "Import - Upload Texture Error",MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                        if (res == DialogResult.Yes)
                            UploadImagesRetry();

                        if (FailedUploads.Count != 0)
                        {
                            MessageBox.Show(String.Format("Failed to upload {0} textures on second try, aborting!",FailedUploads.Count),
                                            "Import - Upload Texture Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                            LogMessage("Failed to import object, due to texture error, review the log for further information");
                            return;
                        }
                    }

                    LogMessage("Texture Upload completed");
                    LogMessage("Importing Prims...");
                    // If we get here, then we successfully uploaded the textures, continue with the upload of the Prims.
                    Importer.ImportFromFile(txtFileName.Text);
                    LogMessage("Import successful.");
                    LogMessage("Total Time: {0}",DateTime.Now.Subtract(start));
                }
                catch (Exception ex)
                {
                    LogMessage("Import failed. Reason: {0}",ex.Message);
                    MessageBox.Show(ex.Message,"Importing failed.",MessageBoxButtons.OK,MessageBoxIcon.Error);
                }

                BeginInvoke(new MethodInvoker(() => EnableWindow()));
            }));
            t.IsBackground = true;
            t.Start();
        }
示例#55
0
 /// <summary>
 /// runs in a STA thread (by creating one)  Does not "join"
 /// </summary>
 /// <param name="args"></param>        
 public static void RunInThread(ApartmentState must, ThreadStart runMain, bool blocking)
 {
     if (!blocking || Thread.CurrentThread.ApartmentState != must)
     {
         Thread newThread = new Thread(runMain);
         newThread.SetApartmentState(must);
         newThread.Start();
         if (blocking) newThread.Join();
         return;
     }
     else
     {
         runMain();
     }
 }
        internal HttpJob(JobGiver server, IHttpClientContext context, IHttpRequest request, IHttpResponse response)
        {
            this.Server = server;
            this.Context = context;
            this.Request = request;
            this.Response = response;
            Thread = Thread.CurrentThread;            
#if USE_HTTPSERVER_DLL
            Name = request.UriPath;
#endif
        }
示例#57
0
        ///Configuration config;

        public void startSocketListener()
        {
            // The thread that accepts the Client and awaits messages

            int maxRebinds = 10;
            this.Bound = TryBind(ServerPort);
            while (maxRebinds > 0 && !this.Bound)
            {
                ServerPort = ServerPort + ServerPortIncr;
                this.Bound = TryBind(ServerPort);
                maxRebinds--;
            }
            if (!Bound)
            {
                WriteLine("Gave up on TCPServer");
                return;
            }
            else
            {
                WriteLine("Realy bound " + ServerPort + "!");
            }
            thrSvr = new Thread(tcpSrv);
            thrSvr.Name = ToString();
            // The thread calls the tcpSvr() method=
            thrSvr.Start();



        }
示例#58
0
        void InventoryConsole_Disposed(object sender, EventArgs e)
        {
            if (TreeUpdateTimer != null)
            {
                TreeUpdateTimer.Stop();
                TreeUpdateTimer.Dispose();
                TreeUpdateTimer = null;
            }
            if (InventoryUpdate != null)
            {
                if (InventoryUpdate.IsAlive)
                    InventoryUpdate.Abort();
                InventoryUpdate = null;
            }

            Inventory.InventoryObjectAdded -= new EventHandler<InventoryObjectAddedEventArgs>(Inventory_InventoryObjectAdded);
            Inventory.InventoryObjectUpdated -= new EventHandler<InventoryObjectUpdatedEventArgs>(Inventory_InventoryObjectUpdated);
            Inventory.InventoryObjectRemoved -= new EventHandler<InventoryObjectRemovedEventArgs>(Inventory_InventoryObjectRemoved);

            client.Objects.ObjectUpdate -= new EventHandler<PrimEventArgs>(Objects_AttachmentUpdate);
            client.Objects.KillObject -= new EventHandler<KillObjectEventArgs>(Objects_KillObject);
            client.Appearance.AppearanceSet -= new EventHandler<AppearanceSetEventArgs>(Appearance_AppearanceSet);
        }
示例#59
0
        public override void Dispose()
        {
            if (Instance.Client != null)
                UnregisterClientEvents(Instance.Client);

            lock (sounds)
            {
                for (int i = 0; i < sounds.Count; i++)
                {
                    if (!sounds[i].Disposed)
                        sounds[i].Dispose();
                }
                sounds.Clear();
            }

            sounds = null;

            if (system != null)
            {
                Logger.Log("FMOD interface stopping", Helpers.LogLevel.Info);
                system.release();
                system = null;
            }

            if (listenerThread != null)
            {
                if (listenerThread.IsAlive)
                    listenerThread.Abort();
                listenerThread = null;
            }

            if (soundThread != null)
            {
                if (soundThread.IsAlive)
                    soundThread.Abort();
                soundThread = null;
            }

            base.Dispose();
        }
示例#60
0
        private void btnFolder_Click(object sender, System.EventArgs e)
        {
            openFileDialog1.CheckFileExists = false;
            DialogResult res = openFileDialog1.ShowDialog();
            traversed = 0;

            if (res == DialogResult.OK)
            {
                string dir = Path.GetDirectoryName(openFileDialog1.FileName);
                txtFolderName.Text = folderName = dir;
                btnFolder.Enabled = false;

                lvwFiles.Items.Clear();

                if (cbList.Checked)
                {
                    try
                    {
                        csvFile = new StreamWriter(Path.Combine(dir, "inventory.csv"), false);
                        WriteCSVLine("Type", "Path", "Name", "Description", "Created", "Creator", "Last Owner");
                    }
                    catch
                    {
                        csvFile = null;
                    }
                }

                lblStatus.Text = "Fetching items...";
                sbrProgress.Style = ProgressBarStyle.Marquee;
                fetched = 0;

                if (backupThread != null)
                {
                    if (backupThread.IsAlive)
                        backupThread.Abort();
                    backupThread = null;
                }

                backupThread = new Thread(new ThreadStart(() =>
                {
                    TraverseDir(rootNode, Path.DirectorySeparatorChar.ToString());
                    if (csvFile != null)
                    {
                        try
                        {
                            csvFile.Close();
                            csvFile.Dispose();
                        }
                        catch { }
                    }
                    BeginInvoke(new MethodInvoker(() =>
                    {
                        lblStatus.Text = string.Format("Done ({0} items saved).", fetched);
                        sbrProgress.Style = ProgressBarStyle.Blocks;
                        btnFolder.Enabled = true;
                    }
                    ));
                }
                ));

                backupThread.IsBackground = false;
                backupThread.Name = "Inventory Backup";
                backupThread.Start();

            }
        }