Fixing white space and naming style.

This commit is contained in:
Ima Mechanique 2013-07-18 19:25:38 +01:00
parent 69749abe53
commit 40862a4ad7
4 changed files with 42 additions and 65 deletions

View file

@ -98,11 +98,9 @@ namespace LSLEditor.Helpers
public void Stop() public void Stop()
{ {
if(WorkerThread!=null) if (WorkerThread != null) {
{
WorkerThread.Abort(); WorkerThread.Abort();
if (!WorkerThread.Join(2000)) if (!WorkerThread.Join(2000)) {
{
// problems // problems
System.Windows.Forms.MessageBox.Show("TaskQueue thread not Aborted", "Oops..."); System.Windows.Forms.MessageBox.Show("TaskQueue thread not Aborted", "Oops...");
} }
@ -110,21 +108,18 @@ namespace LSLEditor.Helpers
} }
} }
public void Invoke(object ActiveObject,string MethodName, params object[] args) public void Invoke(object ActiveObject, string MethodName, params object[] args)
{ {
if (ActiveObject == null) if (ActiveObject == null)
return; return;
try try {
{
// Add the object to the internal buffer // Add the object to the internal buffer
Tasks.Enqueue(new Task(ActiveObject, MethodName, args)); Tasks.Enqueue(new Task(ActiveObject, MethodName, args));
// Signal the internal thread that there is some new object in the buffer // Signal the internal thread that there is some new object in the buffer
SignalNewTask.Set(); SignalNewTask.Set();
} } catch (Exception e) {
catch (Exception e) Trace.WriteLine(string.Format("An exception occurred in TaskQueue.Invoke: {0}", e.Message));
{
Trace.WriteLine(string.Format("I An exception occurred in TaskQueue.Invoke: {0}", e.Message));
// Since the exception was not actually handled and only logged - propagate it // Since the exception was not actually handled and only logged - propagate it
throw; throw;
} }
@ -139,32 +134,24 @@ namespace LSLEditor.Helpers
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US", false); Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US", false);
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US", false); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US", false);
while (!stop) while (!stop) {
{ try {
try
{
// Note: this code is safe (i.e. performing the .Count and .Dequeue not inside a lock) // Note: this code is safe (i.e. performing the .Count and .Dequeue not inside a lock)
// because there is only one thread emptying the queue. // because there is only one thread emptying the queue.
// Even if .Count returns 0, and before Dequeue is called a new object is added to the Queue // Even if .Count returns 0, and before Dequeue is called a new object is added to the Queue
// then still the system will behave nicely: the next if statement will return false and // then still the system will behave nicely: the next if statement will return false and
// since this is run in an endless loop, in the next iteration we will have .Count > 0. // since this is run in an endless loop, in the next iteration we will have .Count > 0.
if (Tasks.Count > 0) if (Tasks.Count > 0) {
{
(Tasks.Dequeue() as Task).Execute(); (Tasks.Dequeue() as Task).Execute();
} }
// Wait until new objects are received or Dispose was called // Wait until new objects are received or Dispose was called
if (Tasks.Count == 0) if (Tasks.Count == 0) {
{
SignalNewTask.WaitOne(); SignalNewTask.WaitOne();
} }
} } catch (ThreadAbortException) {
catch (ThreadAbortException)
{
Trace.WriteLine("TaskQueue.Worker: ThreadAbortException, no problem"); Trace.WriteLine("TaskQueue.Worker: ThreadAbortException, no problem");
} } catch (Exception e) {
catch (Exception e)
{
Trace.WriteLine(string.Format("TaskQueue.Worker: {0}", e.Message)); Trace.WriteLine(string.Format("TaskQueue.Worker: {0}", e.Message));
// Since the exception was not actually handled and only logged - propagate it // Since the exception was not actually handled and only logged - propagate it
throw; throw;
@ -191,17 +178,12 @@ namespace LSLEditor.Helpers
protected virtual void Dispose(bool disposing) protected virtual void Dispose(bool disposing)
{ {
if (!this.disposed) if (!this.disposed) {
{ if (disposing) {
if (disposing) try {
{
try
{
stop = true; stop = true;
SignalNewTask.Set(); SignalNewTask.Set();
} } catch (Exception e) {
catch (Exception e)
{
Trace.WriteLine(string.Format("An exception occurred in MessageLoop.AddToBuffer: {0}", e.Message)); Trace.WriteLine(string.Format("An exception occurred in MessageLoop.AddToBuffer: {0}", e.Message));
// Since the exception was not actually handled and only logged - propagate it // Since the exception was not actually handled and only logged - propagate it
throw; throw;
@ -228,8 +210,7 @@ namespace LSLEditor.Helpers
public void Execute() public void Execute()
{ {
try try {
{
MethodInfo mi = ActiveObject.GetType().GetMethod(MethodName, MethodInfo mi = ActiveObject.GetType().GetMethod(MethodName,
BindingFlags.Public | BindingFlags.Public |
BindingFlags.Instance | BindingFlags.Instance |
@ -237,13 +218,9 @@ namespace LSLEditor.Helpers
BindingFlags.NonPublic BindingFlags.NonPublic
); );
mi.Invoke(ActiveObject, args); mi.Invoke(ActiveObject, args);
} } catch (ThreadAbortException) {
catch (ThreadAbortException)
{
Trace.WriteLine("TaskQueue.Task.Execute: ThreadAbortException, no problem"); Trace.WriteLine("TaskQueue.Task.Execute: ThreadAbortException, no problem");
} } catch (Exception exception) {
catch (Exception exception)
{
Exception innerException = exception.InnerException; Exception innerException = exception.InnerException;
if (innerException == null) if (innerException == null)
innerException = exception; innerException = exception;

View file

@ -2751,7 +2751,7 @@ namespace LSLEditor
public void llSensor(String sName, key kID, integer iType, Float fRange, Float fArc) public void llSensor(String sName, key kID, integer iType, Float fRange, Float fArc)
{ {
Verbose(@"llSensor(""{0}"", {1}, {2}, {3}, {4})", sName, kID, iType, fRange, fArc); Verbose(@"llSensor(""{0}"", {1}, {2}, {3}, {4})", sName, kID, iType, fRange, fArc);
host.sensor_timer.Stop(); host.SensorTimer.Stop();
integer iTotalNumber = 1; integer iTotalNumber = 1;
host.ExecuteSecondLife("sensor", iTotalNumber); host.ExecuteSecondLife("sensor", iTotalNumber);
} }
@ -2759,16 +2759,16 @@ namespace LSLEditor
public void llSensorRemove() public void llSensorRemove()
{ {
Verbose("llSensorRemove()"); Verbose("llSensorRemove()");
host.sensor_timer.Stop(); host.SensorTimer.Stop();
} }
public void llSensorRepeat(String sName, key kID, integer iType, Float fRange, Float fArc, Float fRate) public void llSensorRepeat(String sName, key kID, integer iType, Float fRange, Float fArc, Float fRate)
{ {
Verbose(@"llSensorRepeat(""{0}"", {1}, {2}, {3}, {4}, {5})", sName, kID, iType, fRange, fArc, fRate); Verbose(@"llSensorRepeat(""{0}"", {1}, {2}, {3}, {4}, {5})", sName, kID, iType, fRange, fArc, fRate);
host.sensor_timer.Stop(); host.SensorTimer.Stop();
if (fRate > 0) { if (fRate > 0) {
host.sensor_timer.Interval = (int)Math.Round(fRate * 1000); host.SensorTimer.Interval = (int)Math.Round(fRate * 1000);
host.sensor_timer.Start(); host.SensorTimer.Start();
} }
} }
@ -3028,10 +3028,10 @@ namespace LSLEditor
public void llSetTimerEvent(Float fSeconds) public void llSetTimerEvent(Float fSeconds)
{ {
Verbose("llSetTimerEvent({0})", fSeconds); Verbose("llSetTimerEvent({0})", fSeconds);
host.timer.Stop(); host.Timer.Stop();
if (fSeconds > 0) { if (fSeconds > 0) {
host.timer.Interval = (int)Math.Round(fSeconds * 1000); host.Timer.Interval = (int)Math.Round(fSeconds * 1000);
host.timer.Start(); host.Timer.Start();
} }
} }

View file

@ -33,7 +33,7 @@
// </copyright> // </copyright>
// //
// <summary> // <summary>
// // vector.cs
// //
// </summary> // </summary>

View file

@ -116,7 +116,7 @@ namespace LSLEditor
this.Listen(e); this.Listen(e);
// talk only to the owner // talk only to the owner
if (e.how != CommunicationType.OwnerSay) { if (e.How != CommunicationType.OwnerSay) {
foreach (Form form in this.Children) { foreach (Form form in this.Children) {
EditForm editForm = form as EditForm; EditForm editForm = form as EditForm;
if (editForm == null || editForm.IsDisposed) { if (editForm == null || editForm.IsDisposed) {
@ -143,12 +143,12 @@ namespace LSLEditor
{ {
SecondLifeHost secondLifeHostSender = sender as SecondLifeHost; SecondLifeHost secondLifeHostSender = sender as SecondLifeHost;
Guid ObjectGuid = this.solutionExplorer.GetParentGuid(secondLifeHostSender.guid); Guid ObjectGuid = this.solutionExplorer.GetParentGuid(secondLifeHostSender.GUID);
Guid RootObjectGuid = this.solutionExplorer.GetParentGuid(ObjectGuid); Guid RootObjectGuid = this.solutionExplorer.GetParentGuid(ObjectGuid);
List<Guid> list; List<Guid> list;
int intLinkNum = e.iLinkIndex; int intLinkNum = e.LinkIndex;
switch (intLinkNum) { switch (intLinkNum) {
case 1: // LINK_ROOT , root prim in linked set (but not in a single prim, which is 0) case 1: // LINK_ROOT , root prim in linked set (but not in a single prim, which is 0)
list = this.solutionExplorer.GetScripts(RootObjectGuid, false); list = this.solutionExplorer.GetScripts(RootObjectGuid, false);
@ -251,28 +251,28 @@ namespace LSLEditor
{ {
// Translate the incomming messages a bit so it looks like SL. // Translate the incomming messages a bit so it looks like SL.
string strHow = ": "; string strHow = ": ";
if (e.how == CommunicationType.Shout) { if (e.How == CommunicationType.Shout) {
strHow = " shout: "; strHow = " shout: ";
} }
if (e.how == CommunicationType.Whisper) { if (e.How == CommunicationType.Whisper) {
strHow = " whispers: "; strHow = " whispers: ";
} }
string strWho = e.name; string strWho = e.Name;
string strMessage = e.message; string strMessage = e.Message;
if (e.name == Properties.Settings.Default.AvatarName) { if (e.Name == Properties.Settings.Default.AvatarName) {
strWho = "You"; strWho = "You";
} }
if (e.message.ToString().StartsWith("/me")) { if (e.Message.ToString().StartsWith("/me")) {
strWho = e.name; strWho = e.Name;
strHow = " "; strHow = " ";
strMessage = e.message.ToString().Substring(3).Trim(); strMessage = e.Message.ToString().Substring(3).Trim();
} }
if (e.channel == 0) { if (e.Channel == 0) {
TalkToSimulatorConsole(strWho + strHow + strMessage); TalkToSimulatorConsole(strWho + strHow + strMessage);
} }
} }