|
i have got an eventhandler say evntHnadler , and i want to add another event that should be fired when the "evntHnadler" is fired , but before that i want to check if my second event is already registered with "evntHnadler " or not , any idea how to do it ...
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:24am.
|
|
|
|
|
thanx this is ok for custom created events, but the problem is i'm trying to get the invocationlist from the button1.click, any idea ?
|
|
|
|
|
Hi to all,
How naming controls in C# ?
for example if you have a button for Register , a good name for this button is btnRegister
Button=btn
Label = lbl
TextBox = txt
PictureBox =? and other controls
|
|
|
|
|
|
that would be OK. It is your choice. Or your company's.
|
|
|
|
|
yes,it's true
but i want to find good way for naming controls
|
|
|
|
|
buttonAdd
buttonDelete
labelName
textBoxName
pictureBoxPerson
|
|
|
|
|
Hi Guys,
I have two Question.
1) How does the CLR recognize whether the assembly has been manipulated or not?
2) “The combination of hashing and digital signing allows .NET to protect your assemblies from tampering” –
Explain in steps how this is achieved in dot net.
do u have any ideas?
|
|
|
|
|
How can I use the VS2008 profiler to profile UI Thread ?
When I use it to profile my winform, It recorded only the function executed on the Main threadm and not the UI thread.
Thanks,
Berlus
|
|
|
|
|
I think I've found the problem, the function was inlined, so its name doesn't appear in the performance report.
Does anyone know how to measure such functions ?
Thanks,
Eyal
|
|
|
|
|
Hi everyone, I am having very hardtime manipulating the compact datagrid. I don't know how it is work, but it is not like windows datagridview at all. Can any one please help me how do I load data from a string array to the grid , row and columns wise.
thanks very much in advance.
|
|
|
|
|
This is not a C# question, it's more appropriate in and you've posted in the Mobile Development forum so wait for an answer in there.
|
|
|
|
|
Please look at the code below :
private void button1_Click(object sender, EventArgs e)
{
for (int j = 0; j < 3; j++)
{
i = j;
myCurThread = new Thread(new ThreadStart(myThread));
myCurThread.Start();
myCurThread.Join();
}
}
private void myThread()
{
string result = "";
myComport = new ComPort();
myComport.Device = "COM5";
myComport.BaudRate = 115200;
myComport.HardwareFlowControl = myComport.asFLOWCONTROL_ENABLE;
myComport.DataBits = (short)myComport.asDATABITS_DEFAULT;
myComport.StopBits = (short)myComport.asSTOPBITS_DEFAULT;
myComport.Parity = (short)myComport.asPARITY_DEFAULT;
myComport.ComTimeout = 8000;
myComport.Open();
string strUSSD = "AT+CUSD=1,\"" + "*444#" + "\",15";
myComport.WriteString(strUSSD);
if (myComport.LastError == 0)
{
result = myComport.ReadString();
while(result.IndexOf("Result") == -1)
{
result = myComport.ReadString();
Debug.WriteLine("i = " + i + " " + result);
}
}
myComport.Close();
}
Problem is, Thread.Join make the button "halt". This is understandable since Thread.Join will make main thread wait until the other thread is finish.
How to make so the button will not "halt" and the threads is run on order? (Thread 2 wait until thread 1 finish and so on).
Is there any alternative to Thread.Join?
|
|
|
|
|
The threads were useless this way..
eidt: nvm, I see what you want now. Why not just make 1 thread?
|
|
|
|
|
Thank you harold for the suggestion.
Why not 1 Thread? it's because i need to simulate 3 or more request to thread at almost the same time.
I need the thread to run in order (2nd thread wait until 1st thread finis and so on).
|
|
|
|
|
If you need the threads to run in order, then they are not 'at the same time' but after eachother.
It only helps to make 3 threads then if you want to synchronize the start of thread 2 with the middle of thread 1, so there can be a bit of overlap. If no overlap is allowed you just get this:
[ 1 ][ 2 ][ 3 ]
You might as well do this, it has the same length, but a different thread is doing the work:
[ 1 ][ 1 ][ 1 ]
And that is, of course, the same as:
[ 1 ]
Because a thread is already synchronized with itself.
|
|
|
|
|
Maybe i should explain what i'm trying to do :
I have 4 GSM Modems. 3 Modems for both execute and read the result from AT command and 1 Modem for receive sms from clients.
Clients will send an sms with certain format that can be parse by the application.
Since a GSM Modem can't execute 2 AT command at the same time and also i need the answer from the GSM modem for further process, that's why i need the AT command run by an order.
Clients will send the sms at unpredictable time. There's an event to handle "receive sms".
after an sms received, it will check the sms format. If the format is correct then the thread will be called and run the AT command. The answer from AT command is also unpredictable (sometime fast and sometime it will take a longer time). At the time 1st thread execute AT command, there is new sms came in. the 2nd thread must wait until the 1st thread is finish. And so on.
This is just a small code trying to simulate the situation.
I think Thread.Join is the answer but it will make the UI "halt" (it maybe not a button but a tab page control etc), and that what i'm trying to avoid.
Hope this explanation help understand the problem.
|
|
|
|
|
It's not really clear to me yet, sorry..
|
|
|
|
|
Seems like what you need is a queue object: the SMS-handling thread(s) after processing received messages add their AT command to the queue; the 'AT handler' thread waits on the queue being not-empty and processes the command at the front of the queue.
So - one thread per modem, and one queueing object to coordinate them. Plus the foreground thread that your UI operates on.
Just remember to lock the queue object before any operations that touch it since it is being touched by multiple threads.
|
|
|
|
|
Thanks for the reply Chris.
Chris Trelawny-Ross wrote: So - one thread per modem
Yes, i agree with you. That's the concept on my mind on my "large code".
It will be array of threads.
|
|
|
|
|
I dont have a whole lot of experience with threading, but wouldn't it make sense to have your for loop run on its own thread so when you call Join() it locks the current thread (the new thread your for loop is running on)?
So when your button is clicked launch a new thread that runs your for loop.
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
Thank you Adam for the reply.
Sorry Adam, i didn't quite understand your point of view.
Maybe you can provide some "scratch code"?
|
|
|
|
|
As per usual Luc is correct.
But to accomplish what i was saying try something like this.
* note: this is just written into the browser so im sure it wont compile *
private void button1_Click(object sender, EventArgs e)
{
.. disable button
Thread myThread = new Thread(new ThreadStart(Run))
myThread.Start();
}
private void Run(){
for (int j = 0; j < 3; j++)
{
i = j;
myCurThread = new Thread(new ThreadStart(myThread));
myCurThread.Start();
myCurThread.Join();
}
}
private void myThread()
{
....
}
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
Yes, i think this is what you mean in the first reply.
Yes, it's a good logic, Adam. Can i say this is thread inside a thread?
And yes, i try it and it worked. I will try it on "large code".
Thanks Man!.
|
|
|
|