Click here to Skip to main content
15,900,511 members
Home / Discussions / C#
   

C#

 
GeneralRe: Exception in calling Socket.Accept Pin
e_LA15-May-06 3:49
e_LA15-May-06 3:49 
QuestionRemove empty Items from checkedListBox Pin
mm31011-May-06 1:42
mm31011-May-06 1:42 
AnswerRe: Remove empty Items from checkedListBox Pin
JoeSharp11-May-06 1:59
JoeSharp11-May-06 1:59 
QuestionAdding a panel of specific size to a tabpage Pin
praveenqwe11-May-06 1:14
praveenqwe11-May-06 1:14 
AnswerRe: Adding a panel of specific size to a tabpage Pin
Wjousts11-May-06 2:22
Wjousts11-May-06 2:22 
GeneralRe: Adding a panel of specific size to a tabpage Pin
praveenqwe14-May-06 22:52
praveenqwe14-May-06 22:52 
QuestionDirectX with Windows.Forms controls performance Pin
241411-May-06 0:50
241411-May-06 0:50 
AnswerRe: DirectX with Windows.Forms controls performance Pin
Andy Moore11-May-06 3:37
Andy Moore11-May-06 3:37 
We have a C# program that does 3D animation of using Managed DirectX 9. Like you we have a 3D visualization window and some other Windows Forms controls on the main application window. We have found our performace quite good with this setup.

Try rendering each frame on the UI thread. Try a tight game loop setup rendering a frame then w checking the message queue for mouse clicks, button pushes, etc. I would also recomment doing away with Application.DoEvents() and using P/Invoke to check the message queue. Application.DoEvents() leaks memory with each invocation. A loop looks like the following:

[StructLayout(LayoutKind.Sequential)]
 public struct POINT
 {
   public int x;
   public int y;
 }
 [StructLayout(LayoutKind.Sequential)]
 public struct MSG
  {
     public IntPtr hwnd;
     public uint message;
     public IntPtr wParam;
     public IntPtr lParam;
     public int time;
     POINT pt;
  };

public class RenderLoop
{
  

  [DllImport("user32.dll")]
  public static extern bool PeekMessage( out MSG msg, IntPtr hwnd, uint wMsgFilterIn, uint wMsgFilterOut, uint wRemoveMsg );
  public RenderLoop()
  {
    Application.Idle += new EventHandler( this.Application_Idle );
  }
  private bool AppStillIdle
  {
      MSG msg;
   
      return (!PeekMessage( out msg, IntPtr.Zero, 0, 0, 0 ) );
  }

  public void Application_Idle( object sender, EventArgs e )
  {
      while( AppStillIdle )
      {
          RenderFrame();
      }
  }
}


So each time your application gets an idle message you will render frames until the next UI event comes to your message queue. The application will process this event, then go back into the Application_Idle method and continue rendering frames until the next mouse click, etc.

I hope this helps.


Deus caritas est
GeneralRe: DirectX with Windows.Forms controls performance Pin
241411-May-06 3:54
241411-May-06 3:54 
GeneralRe: DirectX with Windows.Forms controls performance Pin
Andy Moore11-May-06 6:46
Andy Moore11-May-06 6:46 
GeneralRe: DirectX with Windows.Forms controls performance Pin
241411-May-06 7:17
241411-May-06 7:17 
GeneralRe: DirectX with Windows.Forms controls performance Pin
Andy Moore11-May-06 7:38
Andy Moore11-May-06 7:38 
GeneralRe: DirectX with Windows.Forms controls performance Pin
241411-May-06 8:12
241411-May-06 8:12 
GeneralRe: DirectX with Windows.Forms controls performance Pin
Andy Moore11-May-06 8:21
Andy Moore11-May-06 8:21 
QuestionBuild Windows application from command prompt Pin
KishoreT11-May-06 0:45
KishoreT11-May-06 0:45 
AnswerRe: Build Windows application from command prompt Pin
Stefan Troschuetz11-May-06 0:58
Stefan Troschuetz11-May-06 0:58 
GeneralRe: Build Windows application from command prompt Pin
KishoreT11-May-06 1:33
KishoreT11-May-06 1:33 
GeneralRe: Build Windows application from command prompt Pin
Stefan Troschuetz11-May-06 3:33
Stefan Troschuetz11-May-06 3:33 
QuestionProblem in Passing structure by reference in c# Pin
analytiks11-May-06 0:39
analytiks11-May-06 0:39 
AnswerRe: Problem in Passing structure by reference in c# Pin
S. Senthil Kumar11-May-06 5:11
S. Senthil Kumar11-May-06 5:11 
QuestionUse c# dll in vb.6 Pin
Cliffer11-May-06 0:27
Cliffer11-May-06 0:27 
AnswerRe: Use c# dll in vb.6 Pin
Dave Kreskowiak11-May-06 3:45
mveDave Kreskowiak11-May-06 3:45 
AnswerRe: MVC game design question Pin
Robert Rohde11-May-06 1:01
Robert Rohde11-May-06 1:01 
Questionstrange problem Pin
rah_sin10-May-06 23:14
professionalrah_sin10-May-06 23:14 
AnswerRe: strange problem Pin
alexey N10-May-06 23:43
alexey N10-May-06 23:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.