Click here to Skip to main content
15,912,977 members
Home / Discussions / C#
   

C#

 
GeneralRe: Designing: Multiple interfaces implementation on classes Pin
jschell9-Nov-11 11:13
jschell9-Nov-11 11:13 
GeneralRe: Designing: Multiple interfaces implementation on classes Pin
Ravi Sant10-Nov-11 2:29
Ravi Sant10-Nov-11 2:29 
AnswerRe: Designing: Multiple interfaces implementation on classes PinPopular
BobJanova8-Nov-11 23:15
BobJanova8-Nov-11 23:15 
GeneralRe: Designing: Multiple interfaces implementation on classes Pin
vinayvraman9-Nov-11 0:34
vinayvraman9-Nov-11 0:34 
AnswerRe: Designing: Multiple interfaces implementation on classes Pin
Ravi Bhavnani9-Nov-11 2:07
professionalRavi Bhavnani9-Nov-11 2:07 
GeneralRe: Designing: Multiple interfaces implementation on classes Pin
vinayvraman9-Nov-11 3:58
vinayvraman9-Nov-11 3:58 
AnswerRe: Designing: Multiple interfaces implementation on classes Pin
BillWoodruff10-Nov-11 5:49
professionalBillWoodruff10-Nov-11 5:49 
QuestionHow to Sleep a Thread? Pin
namelkcip8-Nov-11 16:46
namelkcip8-Nov-11 16:46 
I am working on a C# WPF application that makes use of the OpenNET CF Desktop Communication library. My program waits for an Active Sync connection and uploads a small EXE. The EXE gets the device manufacturer and model and writes them to text files. I then copy those text files back to the desktop PC to grab that data. I wish I knew how to run those over a socket, but that's for another day. I would like to create a separate thread so that I don't block the main UI. This separate thread must NOT complete until it detects that the EXE I uploaded has finished and created the text files. I would like to have it essentially sleep for 1 second and check, and if it gets to more than 5 seconds alert the user that an error occurred. The problem I'm having is figuring out how to sleep the thread. I'm using a while loop that runs so long as those text files are not present. Once I go into a while loop, all variables are local. As a result, I cannot access the DispatcherOperator so I can invoke the sleep in the form of a 'Wait'. In place of it I am currently sleeping the main thread, but this blocks the UI. How can I achieve the effect of this separate thread waiting for the text files to be output by the EXE I uploaded to the mobile computer, but also not blocking the main UI?
<pre lang="c#">
private void MonitorOEMInfoProcess()
{
System.Threading.Thread MonitorThread = new System.Threading.Thread(
     new System.Threading.ThreadStart(
          delegate()
             {
                System.Windows.Threading.DispatcherOperation dispatcherOp = Dispatcher.BeginInvoke(
                            System.Windows.Threading.DispatcherPriority.Normal,
     new Action(
         delegate()
             {
                while (!m_rapi.DeviceFileExists(@"\Application\OEMName.txt") || !m_rapi.DeviceFileExists(@"\Application\OEMVersion.txt"))
                                    {
                                        System.Threading.Thread.Sleep(1000);
                                        //dispatcherOp.Wait(TimeSpan.FromMilliseconds(1000));
                                    }
                                }
                        ));

                        dispatcherOp.Completed += new EventHandler(dispatcherOp_Completed);
                    }
            ));
            MonitorThread.Start();
        }

AnswerRe: How to Sleep a Thread? Pin
lukeer8-Nov-11 22:00
lukeer8-Nov-11 22:00 
GeneralRe: How to Sleep a Thread? Pin
namelkcip10-Nov-11 4:40
namelkcip10-Nov-11 4:40 
GeneralRe: How to Sleep a Thread? Pin
lukeer10-Nov-11 21:04
lukeer10-Nov-11 21:04 
AnswerRe: How to Sleep a Thread? Pin
BobJanova8-Nov-11 23:19
BobJanova8-Nov-11 23:19 
QuestionWhat am I doing wrong? Pin
Member 83630848-Nov-11 15:33
Member 83630848-Nov-11 15:33 
AnswerRe: What am I doing wrong? Pin
Hum Dum8-Nov-11 17:09
Hum Dum8-Nov-11 17:09 
AnswerRe: What am I doing wrong? Pin
RobCroll8-Nov-11 17:09
RobCroll8-Nov-11 17:09 
QuestionAce OLE driver with Extended Properties Pin
Alaric_8-Nov-11 10:18
professionalAlaric_8-Nov-11 10:18 
AnswerRe: Ace OLE driver with Extended Properties Pin
Dave Kreskowiak8-Nov-11 13:28
mveDave Kreskowiak8-Nov-11 13:28 
GeneralRe: Ace OLE driver with Extended Properties Pin
Alaric_15-Nov-11 9:59
professionalAlaric_15-Nov-11 9:59 
QuestionRemoving Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte8-Nov-11 8:06
KairuByte8-Nov-11 8:06 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
harold aptroot8-Nov-11 8:37
harold aptroot8-Nov-11 8:37 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte8-Nov-11 8:50
KairuByte8-Nov-11 8:50 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
harold aptroot8-Nov-11 9:01
harold aptroot8-Nov-11 9:01 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte8-Nov-11 9:06
KairuByte8-Nov-11 9:06 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
harold aptroot8-Nov-11 9:10
harold aptroot8-Nov-11 9:10 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte8-Nov-11 9:16
KairuByte8-Nov-11 9:16 

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.