Click here to Skip to main content
16,010,553 members
Home / Discussions / C#
   

C#

 
QuestionHow to call ITAddressTranslation method Pin
Fredy16-Sep-05 1:08
Fredy16-Sep-05 1:08 
QuestionC# and voice chat Pin
pakFari16-Sep-05 1:07
pakFari16-Sep-05 1:07 
QuestionDateTime search with Data Tables "Select" Method Pin
16-Sep-05 0:50
suss16-Sep-05 0:50 
Questionimage on toolbarbutton Pin
g00fyman16-Sep-05 0:46
g00fyman16-Sep-05 0:46 
AnswerRe: image on toolbarbutton Pin
Subrahmanyam K16-Sep-05 1:01
Subrahmanyam K16-Sep-05 1:01 
GeneralRe: image on toolbarbutton Pin
g00fyman16-Sep-05 1:07
g00fyman16-Sep-05 1:07 
AnswerRe: image on toolbarbutton Pin
mav.northwind16-Sep-05 5:05
mav.northwind16-Sep-05 5:05 
QuestionThread and timer problem Pin
NicklasRing15-Sep-05 23:41
NicklasRing15-Sep-05 23:41 
Hi
I'm trying to start a timer event from another event. A event is activated from an external button through the parallellport.
This works perfect. I can fire almost anything, but not the timer. I want to start a countdown when i press the external button. The timer starts if I start it from a formbutton.

Please help.

//Nicklas

Here is part of my code:

public delegate void PortDataHandler(object sender, MyDataEventArgs e);
private System.Threading.ThreadStart threadStart;
private System.Threading.Thread thread;
public event PortDataHandler OnPortDataChange;
Timer timer1 = new Timer();

private void Form1_Load(object sender, System.EventArgs e)
{


drive();


}

private void drive()
{
//my timer
timer1.Tick += new EventHandler(Ticker);
timer1.Interval = 1000;


//my event
OnPortDataChange += new PortDataHandler(my_Handler);
this.threadStart = new System.Threading.
ThreadStart(Application_Tick);
this.thread = new System.Threading.Thread(threadStart);
this.thread.Start();
}

public class MyDataEventArgs : EventArgs
{
public readonly int TheNumber;

public MyDataEventArgs(int num)
{
TheNumber = num;
}

}
public void Application_Tick()
{
while ((Input(889)==120))
{
}

OnPortDataChange(this, new MyDataEventArgs(Input(889)));


drive();

}


void Ticker(object sender, EventArgs e)
{

//do something every second
}

public void my_counter()
{

label1.Text="now you are here";

timer1.Start(); //the timer don't start from here



}



public void my_Handler(object sender, MyDataEventArgs e)
{

this.label2.Text="You pressed the button!!";
my_counter();
//PlaySound( "C:/mina mappar/project programming/play2/sound.wav", 0, 1 );
//timer1.start(); //timer dont start here



private void button1_Click(object sender, System.EventArgs e)
{

//label1.Text="vanliga knappen";
this.thread.Abort();
this.Close();

//OnPortDataChange(this, new MyDataEventArgs(Input(889)));
}

private void button2_Click(object sender, System.EventArgs e)
{
timer1.Start(); //the timer start here????????? but not where i want.

}


}
}
AnswerRe: Thread and timer problem Pin
mav.northwind16-Sep-05 21:50
mav.northwind16-Sep-05 21:50 
QuestionCLR Pin
Anonymous15-Sep-05 23:37
Anonymous15-Sep-05 23:37 
AnswerRe: CLR Pin
Guffa15-Sep-05 23:57
Guffa15-Sep-05 23:57 
QuestionJoin video on-the-fly Pin
karnalta15-Sep-05 23:36
karnalta15-Sep-05 23:36 
QuestionHow to use < sign in comments? Pin
Dr Reedo15-Sep-05 23:09
Dr Reedo15-Sep-05 23:09 
AnswerRe: How to use < sign in comments? Pin
g00fyman15-Sep-05 23:17
g00fyman15-Sep-05 23:17 
GeneralRe: How to use &lt; sign in comments? Pin
Dr Reedo16-Sep-05 1:16
Dr Reedo16-Sep-05 1:16 
GeneralRe: How to use &lt; sign in comments? Pin
g00fyman16-Sep-05 1:17
g00fyman16-Sep-05 1:17 
QuestionProblems with Array being readonly (HELP) Pin
Yannielsen15-Sep-05 22:28
Yannielsen15-Sep-05 22:28 
GeneralRe: Problems with Array being readonly (HELP) Pin
Guffa16-Sep-05 0:31
Guffa16-Sep-05 0:31 
GeneralRe: Problems with Array being readonly (HELP) Pin
Yannielsen16-Sep-05 0:56
Yannielsen16-Sep-05 0:56 
GeneralRe: Problems with Array being readonly (HELP) Pin
Guffa16-Sep-05 1:59
Guffa16-Sep-05 1:59 
GeneralRe: Problems with Array being readonly (HELP) Pin
Yannielsen16-Sep-05 2:12
Yannielsen16-Sep-05 2:12 
GeneralRe: Problems with Array being readonly (HELP) Pin
Guffa16-Sep-05 5:11
Guffa16-Sep-05 5:11 
GeneralRe: Problems with Array being readonly (HELP) Pin
Yannielsen19-Sep-05 10:13
Yannielsen19-Sep-05 10:13 
QuestionDataGrid/DataGridBoolColumn - event Pin
JuergenLissmann15-Sep-05 21:48
JuergenLissmann15-Sep-05 21:48 
QuestionHow to override the Text property of Control class? Pin
dreamwinter15-Sep-05 20:54
dreamwinter15-Sep-05 20:54 

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.