• Advertisement

kanato

Member
  • Content count

    350
  • Joined

  • Last visited

Community Reputation

568 Good

About kanato

  • Rank
    Member
  1. You should be responding to mouse move events instead of using a timer. There's simply no way to track the mouse over every single pixel it crosses when it's moving at high speed, so you need to just keep track of the last point you drew at, and when you get a new mouse position event, draw a line to connect the two points.
  2. Is your code optimized? Make sure the optimize code check box is unchecked in your project properties, or that you are using the debug configuration and try it again. The other time I can think of when this can happen is if the code is stopped inside a call to a native function. If that's the case, do "Step out" once to get the current instruction back inside managed code.
  3. You can't "really" multiply a quaternion by a vector. But quaternions are used to represent rotation matrices and you can multiply a matrix by a vector. Multiplying a quaternion by a vector like that is an abuse of operator overloading, IMO. I would say try using Matrix.CreateFromQuaternion(quaternion) * myvector to do the multiplication. Oh, and you can't do *this in C#...
  4. In your finalizer, you should store the handle ID in an external list and then check that list periodically and release the buffers in that list. Or if you want to throw an exception for an unreleased resource, you should do it there instead of the finalizer thread.
  5. [.net] LINQ in C#

    probably something like List<string> data = new List<string>(); data.AddRange(from someString in myList select someString where IsValidData(someString )); and then write the function IsValidData to do your data validation.
  6. [.net] Generic Reflection

    Call methodInfo.MakeGenericMethod: http://msdn.microsoft.com/en-us/library/system.reflection.methodinfo.makegenericmethod.aspx
  7. AFAIK, the only way to release a loaded assembly is to load it into a separate AppDomain at the beginning, and then unload the AppDomain.
  8. Would it be preferred to use CultureInfo.InvariantCulture instead of CultureInfo.GetCultureInfo("en-us")?
  9. Ah, yes. You can write your own Invoke and BeginInvoke methods to handle this sort of thing. A general way to do that sort of thing would be like this: class DebuggerThreadInterface { Thread myThread; List<MethodToInvoke> methods = new List<MethodToInvoke>(); class MethodToInvoke { public Delegate Method; public object[] Args; } // Check to see if the method being called is on the correct thread public bool InvokeRequired { get { return Thread.CurrentThread != myThread; } } public void BeginInvoke(Delegate method, params object[] args) { lock(methods) { methods.Add( new MethodToInvoke { Method = method, Args = args } ); } } public void Invoke(Delegate method, params object[] args) { MethodToInvoke x = new MethodToInvoke { Method = method, Args = args } ); lock(methods) { methods.Add(x); } bool executed = false; while (!executed) { Thread.Sleep(10); lock(methods) { executed = !methods.Contains(x); } } } void ThreadMain() { while(shouldRunThread) { ExecuteMethods(); // do important stuff, and maybe call Thread.Sleep } } void ExecuteMethods() { lock(methods) { while (methods.Count > 0) { methods[0].Method.DynamicInvoke(args) methods.RemoveAt(0); } } } } This assumes the MTA thread is run on the DebuggerThreadInterface.ThreadMain method, and that method runs in a loop that maybe checks stuff, sleeps when it needs to, so that it can check to see if methods have been added to the invoke list. Depending on your needs, you may benefit from an approach which is more tailored to your problem domain. (Note: I wrote the above code off the top of my head and it's untested, and may not be the best thread handling code avaialble. Use at own risk :)
  10. What makes you think it runs in STA? Are you setting the apartment state before calling Start on it? Have you checked GetApartmentState on the thread after starting it? You might check Thread.CurrentThread.GetApartmentState in the method that fails to make sure it's running on the thread you think it is.
  11. Create a separate thread to run your debugging commands on, and call SetApartmentState on it to change it to MTA. If you want to run GUI commands on that thread, you must use the Invoke or BeginInvoke methods on your WinForms objects.
  12. When you call GL.GenTextures, you get an integer that you store in the variable target. You need to store that and use it in your call to GL.BindTexture when drawing with the texture.
  13. Because a cast throws an exception if the object being cast is not of the desired type. You want to either use the "is" operator first to see if a cast will be valid, or use the "as" operator to do the cast and check for null afterwords. DialogueTreeNode node = e.Node as DialogueTreeNode); if(node != null) { activatesQuestComboBox.SelectedIndex = node._activatesQuestID; } // or: if(node is DialogueTreeNode) { DialogueTreeNode node = (DialogueTreeNode)e.Node; activatesQuestComboBox.SelectedIndex = node._activatesQuestID; }
  14. [.net] Naming property fields

    Yeah, I don't like it either. It isn't too bad usually, because the field will be private and only visible within that class so the "damage" from breaking the convention is mitigated. I prefer to use the convention of prefixing member fields with 'm' and static fields with 's'. You don't _have_ to follow the convention on this unless your employer says otherwise.
  15. Released: SharpExtensions

    There's no download link on the page.
  • Advertisement