Click here to Skip to main content
15,898,035 members
Home / Discussions / C#
   

C#

 
AnswerRe: LastIndexOf("") in C# Pin
Vikram A Punathambekar8-Aug-07 21:45
Vikram A Punathambekar8-Aug-07 21:45 
AnswerRe: LastIndexOf("") in C# Pin
Luc Pattyn9-Aug-07 0:57
sitebuilderLuc Pattyn9-Aug-07 0:57 
QuestionWindows Form Pin
sangramkp8-Aug-07 19:37
sangramkp8-Aug-07 19:37 
AnswerRe: Windows Form Pin
Christian Graus8-Aug-07 19:41
protectorChristian Graus8-Aug-07 19:41 
QuestionSwitching between two threads Pin
praveen pandey8-Aug-07 18:48
praveen pandey8-Aug-07 18:48 
AnswerRe: Switching between two threads Pin
Leslie Sanford8-Aug-07 19:41
Leslie Sanford8-Aug-07 19:41 
GeneralRe: Switching between two threads Pin
praveen pandey8-Aug-07 19:55
praveen pandey8-Aug-07 19:55 
GeneralRe: Switching between two threads Pin
Leslie Sanford8-Aug-07 21:41
Leslie Sanford8-Aug-07 21:41 
praveen pandey wrote:
It's a windows app.


Ok, well in your thread loop, you could marshal a delegate invocation to the main thread:

private void ThreadMethod()
{    
    lock(lockObject)    
    {         
        while(someConditionIsTrue)        
        {            
            Monitor.Wait(lockObject);             
 
            // Do some work...        
 
            BeginInvoke(new WorkDelegate(DoWorkOnMainThread));
        }    
    }
}
 
private delegate void WorkDelegate();
  
private void DoWorkOnMainThread()
{
    lock(lockObject)
    {
        // Do some work on main thread.
 
        Monitor.Pulse(lockObject);
    }
}


This assumes you're writing a Forms application. The idea is that you have the main thread running and not blocking while the worker thread does its work. Then when you need work done on the main thread, the worker thread marshals a delegate invocation that does the work to the main thread through BeginInvoke. The method on the main thread signals the worker thread when it's done so that the worker thread can continue for another iteration.
GeneralRe: Switching between two threads Pin
praveen pandey8-Aug-07 23:51
praveen pandey8-Aug-07 23:51 
QuestionBypass character in textbox Pin
Edwin Syarief8-Aug-07 17:46
Edwin Syarief8-Aug-07 17:46 
AnswerRe: Bypass character in textbox Pin
-BoBo8-Aug-07 17:52
-BoBo8-Aug-07 17:52 
GeneralRe: Bypass character in textbox [modified] Pin
Edwin Syarief8-Aug-07 17:54
Edwin Syarief8-Aug-07 17:54 
GeneralRe: Bypass character in textbox Pin
Christian Graus8-Aug-07 18:35
protectorChristian Graus8-Aug-07 18:35 
AnswerRe: Bypass character in textbox Pin
Nouman Bhatti8-Aug-07 19:43
Nouman Bhatti8-Aug-07 19:43 
AnswerRe: Bypass character in textbox Pin
Edwin Syarief8-Aug-07 21:27
Edwin Syarief8-Aug-07 21:27 
QuestionUpdating DataSet Pin
-BoBo8-Aug-07 17:29
-BoBo8-Aug-07 17:29 
AnswerRe: Updating DataSet Pin
hamid_m8-Aug-07 19:23
hamid_m8-Aug-07 19:23 
Questiondouble buffering for flickering problem Pin
cyn88-Aug-07 17:10
cyn88-Aug-07 17:10 
AnswerRe: double buffering for flickering problem Pin
Martin#8-Aug-07 20:26
Martin#8-Aug-07 20:26 
AnswerRe: double buffering for flickering problem Pin
Luc Pattyn9-Aug-07 1:04
sitebuilderLuc Pattyn9-Aug-07 1:04 
QuestionFormula - How many address in a range Pin
StevenWalsh8-Aug-07 17:01
StevenWalsh8-Aug-07 17:01 
AnswerRe: Formula - How many address in a range Pin
Christian Graus8-Aug-07 17:29
protectorChristian Graus8-Aug-07 17:29 
GeneralRe: Formula - How many address in a range Pin
StevenWalsh8-Aug-07 18:05
StevenWalsh8-Aug-07 18:05 
GeneralRe: Formula - How many address in a range Pin
Christian Graus8-Aug-07 18:54
protectorChristian Graus8-Aug-07 18:54 
AnswerRe: Formula - How many address in a range Pin
Luc Pattyn9-Aug-07 1:35
sitebuilderLuc Pattyn9-Aug-07 1:35 

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.