Click here to Skip to main content
15,921,837 members
Home / Discussions / C#
   

C#

 
Questioninstance of a crystal report Pin
cellardoor07166-Jul-06 22:25
cellardoor07166-Jul-06 22:25 
AnswerRe: instance of a crystal report Pin
V.7-Jul-06 1:14
professionalV.7-Jul-06 1:14 
QuestionMarshaling Object Pin
Anh_Tuan6-Jul-06 22:22
Anh_Tuan6-Jul-06 22:22 
AnswerRe: Marshaling Object Pin
mav.northwind7-Jul-06 1:14
mav.northwind7-Jul-06 1:14 
GeneralRe: Marshaling Object Pin
Anh_Tuan7-Jul-06 3:20
Anh_Tuan7-Jul-06 3:20 
Questionrunning a function in a thread Pin
Mridang Agarwalla6-Jul-06 22:21
Mridang Agarwalla6-Jul-06 22:21 
AnswerRe: running a function in a thread Pin
Anh_Tuan6-Jul-06 22:32
Anh_Tuan6-Jul-06 22:32 
GeneralRe: running a function in a thread Pin
Adadurov7-Jul-06 0:22
Adadurov7-Jul-06 0:22 
I use to do it like this:

class SomeClass<br />
{<br />
  public Routine1()<br />
  {<br />
    // Show "Wait" cursor (hour-glass)<br />
    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;<br />
<br />
    // reset completion flag<br />
    workDone = false;<br />
<br />
    ThreadStart ts = new ThreadStart(DoWorkWithStatusChecking);<br />
    Thread t = new Thread(ts);<br />
    t.Start();<br />
<br />
    // in this loop we wait for completion and<br />
    // processing GUI messages.<br />
    while( ! t.IsDone this.workDone )<br />
    {<br />
      // If you need to prevent user's interaction with GUI<br />
      // (clicking around, pressing buttons, etc.)<br />
      // you can pass message filter to Application.DoEvents()<br />
      System.Windows.Forms.Application.DoEvents();<br />
      // following line is here to prevent 100% CPU load<br />
      // but some people think it's not necessary<br />
      // i just dont have time to check it, 'cause it works just fine<br />
      Sleep(0);<br />
    }<br />
  }<br />
<br />
  bool workDone = false;<br />
<br />
  void DoWorkWithStatusChecking()<br />
  {<br />
    // This is what you want to do after status-checking.<br />
    if( this.Status )<br />
    {<br />
    }<br />
    else<br />
    {<br />
    }<br />
<br />
    // ... done, set <br />
    this.workDone = true;<br />
  }<br />
<br />
  bool CheckStatus()<br />
  {<br />
    // ... real status checking here<br />
<br />
    return ( true | false );<br />
  }<br />
} // end class SomeClass



Note: routine1 is not reenterable and must be guarded by some sort of guard condition in the beginning!

got the idea?

Alexei.
Questioncreate custom database [modified] Pin
z1z16-Jul-06 22:14
z1z16-Jul-06 22:14 
AnswerRe: create custom database Pin
Paul Conrad6-Jul-06 23:18
professionalPaul Conrad6-Jul-06 23:18 
Questioncombo box issue Pin
V.6-Jul-06 22:10
professionalV.6-Jul-06 22:10 
Questionexporting int array from c++ dll to c# client Pin
Tugberk_Kara6-Jul-06 22:07
Tugberk_Kara6-Jul-06 22:07 
QuestionOutlook automation in Citrix MetaFrame supresses notifications [modified] Pin
Corinna John6-Jul-06 22:03
Corinna John6-Jul-06 22:03 
QuestionMousePosition vs lParam Pin
syedhassan46-Jul-06 21:11
syedhassan46-Jul-06 21:11 
AnswerRe: MousePosition vs lParam Pin
fang_eric6-Jul-06 21:20
fang_eric6-Jul-06 21:20 
Questionhourglass mouse still clicking Pin
lushgrass6-Jul-06 19:53
lushgrass6-Jul-06 19:53 
AnswerRe: hourglass mouse still clicking Pin
Nader Elshehabi6-Jul-06 20:38
Nader Elshehabi6-Jul-06 20:38 
GeneralRe: hourglass mouse still clicking Pin
lushgrass6-Jul-06 21:02
lushgrass6-Jul-06 21:02 
AnswerRe: hourglass mouse still clicking Pin
Nader Elshehabi6-Jul-06 21:22
Nader Elshehabi6-Jul-06 21:22 
GeneralRe: hourglass mouse still clicking Pin
lushgrass6-Jul-06 22:24
lushgrass6-Jul-06 22:24 
AnswerRe: hourglass mouse still clicking Pin
Nader Elshehabi6-Jul-06 22:58
Nader Elshehabi6-Jul-06 22:58 
GeneralRe: hourglass mouse still clicking Pin
lushgrass6-Jul-06 23:21
lushgrass6-Jul-06 23:21 
AnswerRe: hourglass mouse still clicking Pin
Nader Elshehabi7-Jul-06 2:46
Nader Elshehabi7-Jul-06 2:46 
GeneralRe: hourglass mouse still clicking [modified] Pin
lushgrass9-Jul-06 16:59
lushgrass9-Jul-06 16:59 
AnswerRe: hourglass mouse still clicking Pin
Nader Elshehabi9-Jul-06 20:49
Nader Elshehabi9-Jul-06 20:49 

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.