Click here to Skip to main content
15,897,518 members
Home / Discussions / C#
   

C#

 
GeneralRe: Can this be done ? Pin
Steve Murrell3-Apr-03 21:30
Steve Murrell3-Apr-03 21:30 
GeneralRe: Can this be done ? Pin
neroknights4-Apr-03 3:51
neroknights4-Apr-03 3:51 
GeneralRe: Can this be done ? Pin
Steve Murrell4-Apr-03 5:35
Steve Murrell4-Apr-03 5:35 
GeneralFileStream.Seek and Encryption Question Pin
jtmtv182-Apr-03 21:56
jtmtv182-Apr-03 21:56 
QuestionHow to pass a delegate object with parameter as input to a ThreadStart constructor? Pin
Anthony_Yio2-Apr-03 19:52
Anthony_Yio2-Apr-03 19:52 
AnswerRe: How to pass a delegate object with parameter as input to a ThreadStart constructor? Pin
Venkatraman2-Apr-03 20:10
Venkatraman2-Apr-03 20:10 
GeneralRe: How to pass a delegate object with parameter as input to a ThreadStart constructor? Pin
Anthony_Yio2-Apr-03 21:04
Anthony_Yio2-Apr-03 21:04 
GeneralRe: How to pass a delegate object with parameter as input to a ThreadStart constructor? Pin
Venkatraman2-Apr-03 21:26
Venkatraman2-Apr-03 21:26 
GeneralRe: How to pass a delegate object with parameter as input to a ThreadStart constructor? Pin
Anthony_Yio2-Apr-03 21:35
Anthony_Yio2-Apr-03 21:35 
GeneralRe: How to pass a delegate object with parameter as input to a ThreadStart constructor? Pin
Venkatraman2-Apr-03 22:12
Venkatraman2-Apr-03 22:12 
AnswerRe: How to pass a delegate object with parameter as input to a ThreadStart constructor? Pin
Gaul3-Apr-03 4:45
Gaul3-Apr-03 4:45 
GeneralRe: How to pass a delegate object with parameter as input to a ThreadStart constructor? Pin
Anthony_Yio3-Apr-03 14:14
Anthony_Yio3-Apr-03 14:14 
AnswerRe: How to pass a delegate object with parameter as input to a ThreadStart constructor? Pin
neroknights3-Apr-03 9:44
neroknights3-Apr-03 9:44 
GeneralRe: How to pass a delegate object with parameter as input to a ThreadStart constructor? Pin
Anthony_Yio3-Apr-03 14:20
Anthony_Yio3-Apr-03 14:20 
GeneralRe: How to pass a delegate object with parameter as input to a ThreadStart constructor? Pin
Anonymous4-Apr-03 3:45
Anonymous4-Apr-03 3:45 
GeneralShow HTML in Windows Application Pin
D.D. de Kerf2-Apr-03 19:49
D.D. de Kerf2-Apr-03 19:49 
GeneralRe: Show HTML in Windows Application Pin
Stephane Rodriguez.2-Apr-03 20:14
Stephane Rodriguez.2-Apr-03 20:14 
GeneralRe: Show HTML in Windows Application Pin
D.D. de Kerf3-Apr-03 0:59
D.D. de Kerf3-Apr-03 0:59 
GeneralRe: Show HTML in Windows Application Pin
Roger Alsing2-Apr-03 21:53
Roger Alsing2-Apr-03 21:53 
GeneralADSI urgent help required Pin
Venkatraman2-Apr-03 19:15
Venkatraman2-Apr-03 19:15 
GeneralRe: ADSI urgent help required Pin
Velichko Sarev2-Apr-03 20:52
Velichko Sarev2-Apr-03 20:52 
GeneralRe: ADSI urgent help required Pin
Venkatraman2-Apr-03 21:28
Venkatraman2-Apr-03 21:28 
QuestionCWinThread equalant? Pin
bpavi2-Apr-03 10:38
bpavi2-Apr-03 10:38 
AnswerRe: CWinThread equalant? Pin
Oleksandr Kucherenko3-Apr-03 4:56
Oleksandr Kucherenko3-Apr-03 4:56 
Code below implement such thread

<br />
    [DllImport("user32.dll", CharSet=CharSet.Auto)]<br />
    public static extern IntPtr PostThreadMessage( uint idThread, int msg, int wParam, int lParam);<br />
    [DllImport("kernel32.dll", ExactSpelling=true, CharSet=CharSet.Auto)]<br />
    public static extern int GetCurrentThreadId();<br />
    [DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
    public static extern bool PeekMessage(ref MSG msg, int hWnd, uint wFilterMin, uint wFilterMax, uint wFlag);<br />
    [DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
    public static extern bool GetMessage(ref MSG msg, int hWnd, uint wFilterMin, uint wFilterMax);<br />
    [DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
    public static extern bool TranslateMessage(ref MSG msg);<br />
    [DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
    public static extern bool DispatchMessage(ref MSG msg);<br />
<br />
  #region MSG<br />
  [StructLayout(LayoutKind.Sequential)]<br />
  public struct MSG <br />
  {<br />
    public IntPtr hwnd;<br />
    public int message;<br />
    public IntPtr wParam;<br />
    public IntPtr lParam;<br />
    public int time;<br />
    public int pt_x;<br />
    public int pt_y;<br />
  }<br />
  #endregion<br />
<br />
<br />
    /// <summary><br />
    /// Start background message loop thread and show dialog<br />
    /// </summary><br />
    public void AsyncShow()<br />
    {<br />
      if( m_guiThread == null )<br />
      {<br />
        ThreadStart start = new ThreadStart( BackgroundGUIThread );<br />
        m_guiThread = new Thread( start );<br />
        m_guiThread.IsBackground = true;<br />
        m_guiThread.Start();<br />
      }<br />
    }<br />
<br />
    /// <summary><br />
    /// Hide dialog and stop background thread<br />
    /// </summary><br />
    public void Finish()<br />
    {<br />
      try<br />
      {<br />
        lock(this)<br />
        {<br />
          if( m_idThread >= 0 )<br />
          {<br />
            WindowsAPI.PostThreadMessage( (uint)m_idThread, (int)Msg.WM_CLOSE, 0, 0 );<br />
          }<br />
       <br />
          // abort background message loop thread and wait till real thread abort<br />
          m_guiThread.Abort(); <br />
          m_guiThread.Join();<br />
        }<br />
      }<br />
      catch( Exception exc )<br />
      { <br />
        Trace.WriteLine( exc.Message + "\r\n" + exc.StackTrace, "PrgDlg Exception" );<br />
      }<br />
    }<br />
    /// <summary><br />
    /// Background GUI thread<br />
    /// </summary><br />
    private void BackgroundGUIThread()<br />
    {<br />
      Thread.CurrentThread.Name = "Background GUI MsgLoop Thread";<br />
      <br />
      try<br />
      {<br />
        lock( this )<br />
        {<br />
          m_idThread = WindowsAPI.GetCurrentThreadId();<br />
          this.Show();<br />
        }<br />
<br />
        // Create an object for storing windows message information<br />
        MSG msg = new MSG();<br />
<br />
        while( WindowsAPI.GetMessage( ref msg, 0, 0, 0 ) )<br />
        {<br />
          WindowsAPI.TranslateMessage( ref msg );<br />
          WindowsAPI.DispatchMessage( ref msg );<br />
          <br />
          if( msg.message == (int)Msg.WM_CLOSE )<br />
          {<br />
            Trace.WriteLine( "Close", "thread (2)" );<br />
            break;<br />
          }<br />
        }<br />
      }<br />
      finally<br />
      {<br />
        Trace.WriteLine( "Quit thread" );<br />
      }<br />
    }<br />


Good Luck
Alex Kucherenko
GeneralRe: CWinThread equalant? Pin
Anonymous4-Apr-03 6:28
Anonymous4-Apr-03 6:28 

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.