Click here to Skip to main content
15,914,111 members
Home / Discussions / C#
   

C#

 
Questionhyperlink in MessageBox? Pin
manusse30-Apr-06 10:03
manusse30-Apr-06 10:03 
AnswerRe: hyperlink in MessageBox? Pin
Graham Nimbley30-Apr-06 10:40
Graham Nimbley30-Apr-06 10:40 
AnswerRe: hyperlink in MessageBox? Pin
Christian Graus30-Apr-06 11:17
protectorChristian Graus30-Apr-06 11:17 
QuestionI want to installed product.. but.... Pin
Real Coder30-Apr-06 8:00
Real Coder30-Apr-06 8:00 
GeneralRe: I want to installed product.. but.... Pin
Guffa30-Apr-06 9:37
Guffa30-Apr-06 9:37 
AnswerRe: I want to installed product.. but.... Pin
Robin Panther30-Apr-06 10:23
Robin Panther30-Apr-06 10:23 
GeneralRe: I want to installed product.. but.... Pin
Real Coder1-May-06 7:03
Real Coder1-May-06 7:03 
QuestionHow to count number of word in text Pin
eyalso30-Apr-06 7:57
eyalso30-Apr-06 7:57 
AnswerRe: How to count number of word in text Pin
Robin Panther30-Apr-06 10:27
Robin Panther30-Apr-06 10:27 
GeneralRe: How to count number of word in text Pin
eyalso30-Apr-06 10:46
eyalso30-Apr-06 10:46 
GeneralRe: How to count number of word in text Pin
Graham Nimbley30-Apr-06 11:35
Graham Nimbley30-Apr-06 11:35 
Questionxml + xslt = html ? Pin
Khepry30-Apr-06 5:47
Khepry30-Apr-06 5:47 
AnswerRe: xml + xslt = html ? Pin
Ravi Bhavnani30-Apr-06 7:41
professionalRavi Bhavnani30-Apr-06 7:41 
QuestionC# ODBC Pin
XeoN-Kc30-Apr-06 4:19
XeoN-Kc30-Apr-06 4:19 
AnswerRe: C# ODBC Pin
Ravi Bhavnani30-Apr-06 7:43
professionalRavi Bhavnani30-Apr-06 7:43 
QuestionSpeech programming Pin
TheEagle30-Apr-06 2:27
TheEagle30-Apr-06 2:27 
AnswerRe: Speech programming Pin
kasik30-Apr-06 10:47
kasik30-Apr-06 10:47 
GeneralRe: Speech programming Pin
TheEagle30-Apr-06 21:24
TheEagle30-Apr-06 21:24 
QuestionRe: Speech programming Pin
TheEagle6-May-06 3:58
TheEagle6-May-06 3:58 
AnswerRe: Speech programming Pin
kasik6-May-06 13:15
kasik6-May-06 13:15 
GeneralRe: Speech programming Pin
TheEagle6-May-06 16:44
TheEagle6-May-06 16:44 
QuestionCreate a thread-safe timer? Pin
Erikerikerikerikerassa30-Apr-06 2:08
Erikerikerikerikerassa30-Apr-06 2:08 
AnswerRe: Create a thread-safe timer? Pin
Ravi Bhavnani30-Apr-06 3:05
professionalRavi Bhavnani30-Apr-06 3:05 
GeneralRe: Create a thread-safe timer? Pin
Erikerikerikerikerassa30-Apr-06 3:43
Erikerikerikerikerassa30-Apr-06 3:43 
http://www.codeproject.com/csharp/begininvoke.asp[^]

Thank's, i've read the article and think i understand what it means. But there is one problem, i want the BeginInvoke to be built in in my timer, now i have to put it everywhere the timmer throws an event in the main form, BeginInvoke is only availible in Forms. I want all the thread-checking to be in the timer-class so i don't have to rewrite it every time i use the timer.

Is it a good idea to send a reference of the main form to the timer and then use BeginInvoke on that reference?
Like this:

class MyTimer
{
    public delegate void TimerTick();
    public event TimerTick tick;
    Thread t;
    Form main;


    public MyTimer(Form f)
    {
        t = new Thread(new ThreadStart(Run));
        main = f;
    }

    public void start()
    {
        t.Start();
    }

    private void Run()
    {
        while (true)
        {
            Thread.Sleep(10);
            main.BeginInvoke(tick);
        }
    }
}

GeneralRe: Create a thread-safe timer? Pin
Ravi Bhavnani30-Apr-06 3:53
professionalRavi Bhavnani30-Apr-06 3:53 

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.