Click here to Skip to main content
15,887,676 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Create a thread-safe timer? Pin
leppie30-Apr-06 7:20
leppie30-Apr-06 7:20 
GeneralRe: Create a thread-safe timer? Pin
Ravi Bhavnani30-Apr-06 7:37
professionalRavi Bhavnani30-Apr-06 7:37 
Questionneed help to pain a picture Pin
f_o_x30-Apr-06 2:02
f_o_x30-Apr-06 2:02 
AnswerRe: need help to pain a picture Pin
CWIZO30-Apr-06 4:15
CWIZO30-Apr-06 4:15 
AnswerRe: need help to pain a picture Pin
Guffa30-Apr-06 5:50
Guffa30-Apr-06 5:50 
Questionvedio files Pin
walaa ibraheem30-Apr-06 0:56
walaa ibraheem30-Apr-06 0:56 
Questionaccessing shared folder in windows application Pin
WCup29-Apr-06 22:15
WCup29-Apr-06 22:15 
AnswerRe: accessing shared folder in windows application Pin
Ravi Bhavnani30-Apr-06 0:52
professionalRavi Bhavnani30-Apr-06 0:52 
QuestionType.Missing and Missing.Value Pin
adityap29-Apr-06 20:55
adityap29-Apr-06 20:55 
AnswerRe: Type.Missing and Missing.Value Pin
Dave Doknjas30-Apr-06 13:45
Dave Doknjas30-Apr-06 13:45 
QuestionProblem in setting icon to TreeView Control Pin
freshonlineMax29-Apr-06 20:27
freshonlineMax29-Apr-06 20:27 
AnswerRe: Problem in setting icon to TreeView Control Pin
tarasn29-Apr-06 22:39
tarasn29-Apr-06 22:39 
GeneralRe: Problem in setting icon to TreeView Control Pin
freshonlineMax29-Apr-06 23:17
freshonlineMax29-Apr-06 23:17 
AnswerRe: Problem in setting icon to TreeView Control Pin
Ravi Bhavnani30-Apr-06 0:55
professionalRavi Bhavnani30-Apr-06 0:55 
AnswerRe: Problem in setting icon to TreeView Control Pin
S. Senthil Kumar30-Apr-06 3:29
S. Senthil Kumar30-Apr-06 3:29 
GeneralRe: Problem in setting icon to TreeView Control Pin
freshonlineMax30-Apr-06 23:04
freshonlineMax30-Apr-06 23:04 

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.