|
Thanks PIEBALDconsult,
1.
We have discussed solutions using only Timer, using only Sleep. Is it possible to have solutions using only Event? (I showed a solution using Timer together with Event, which I think is not good.)
2.
The most concern why I can not find a solution using Event only is, there is no way to check whether a signal is set or not after Wait (with timeout), right?
regards,
George
|
|
|
|
|
1) Not to my knowledge.
2) Those events (which I don't use and hadn't heard of until you mentioned them) require a thread of some sort.
Unless this is homework and you have to use those events, just do what you know works.
|
|
|
|
|
Thanks PIEBALDconsult,
This is not homework. Just my interest to find alternative solutions.
Here is my question showed by the code, it seems there is no way to check whether the signal is set or not after WaitOne(1000) returns, right? So, we can not just use a singal to check the stop condition for a thread, and we need some other approaches to check?
(my previous ideas is to check whether the signal is set or not, if it is set after WaitOne(1000), then I can stop the thread, but after MSDN document study, seems no way to check whether a signal is set or not after WaitOne(1000)?)
static void ThreadMethod3()
{
while (true)
{
CheckEvent.WaitOne (1000);
Console.WriteLine(DateTime.Now);
}
}
regards,
George
|
|
|
|
|
I don't know, I don't use those, I don't foresee a need for them.
|
|
|
|
|
I want to create my own browser,it is like Oicq or icq ,this is his clinet can reration his server.How can I do?help me,thank you!
|
|
|
|
|
lockepeak wrote: it is like Oicq or icq
These are not browsers, they are chat programs. You do it by writing client code, and server code. There is an example here on CP. Odds are you need to buy a book, and choose some more basic projects first.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi All,
I've been reading up on this and all the examples I can find show the exact method I'm using to read a value yet my value is never retrived. I'm checking the version of WMP installed on the system using:
Microsoft.Win32.RegistryKey wmpRegKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Active Setup\Installed Components\{22d6f312-b0f6-11d0-94ab-0080c74c7e95}");
string wmpVersion = (string)wmpRegKey.GetValue("Version");
as soon as the last line is executed the wmpVersion won't even pop up a debugger widget and wmpRegKey won't either.
Any Ideas?
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
using Microsoft.Win32;
//Statements (In your case)
//------------------------------
RegistryKey Reg;
//open the registry key
Reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Active Setup\Installed Components\{22d6f312-b0f6-11d0-94ab-0080c74c7e95}");
//get the requested values
if(Reg!=null)
{
string str1 = Reg.GetValue("Version").ToString();
MessageBox.Show(str1);
}
//close the key
Reg.Close();
//Regards
|
|
|
|
|
Hello
Is there a way to find out if any dataset is attached to a project
i.e. MyPoject.Dataset.count
Thanks
|
|
|
|
|
You'd need to keep that count for yourself.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks for your reply,
i need to write a foreach loop for datasets, how can i write it?
foreach dataset in what?
Thanks again
|
|
|
|
|
Hi there.
I want declare method with optional parameters.
For example I want declare this method :
private void tree (string optional_parameter)
{
...
}
that I could call it like this :
tree();
Id est , I can omit optional_parameter.
Can we do it in C# ?
Sorry for my English. I'm a freshman .
|
|
|
|
|
|
C# doesn't support optional parameters. You achieve this concept by using method overloading.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
Just do as:
private void tree(params string[] optional_parameter)
{
if (optional_parameter.Length > 1)
throw new Exception("tree(): Invalid parameter count");
else if (optional_parameter.Length == 1)
{
}
}
Best regards,
Jaime.
|
|
|
|
|
Thanks , your answer was helpful .
Sorry for my English. I'm a freshman .
|
|
|
|
|
hi
i have a dataGridView and some textBox for each field, i want when i user double click on dataGridView, my controls bind to datasource that my dataGridView bound to, hitherto, it worked correctly and all row information display in appropirate textBox, this is edit mode, i want in this state, user can't change row until click ok or cancel info, but how to prevent row changing in datagridView ?
thanks
|
|
|
|
|
How do i dispaly the files and folders of a site in a tree view or simular format to windows explorer
Thanks
|
|
|
|
|
With a tree view control.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
In grid view Control,How can i represent a check box which is embed in the grid view.
|
|
|
|
|
I am close to certain there's a code project article on how to do this.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
Hello everyone,
I am using the following code segment to check the status of a specific Windows service. My question is, if the service name does not exists, when we tries to get the Status property of the Windows service, there is InvalidOperationException. What is the elegant way to solve this issue (I have not found an API to check whether a service exists, and if I can check whether a service exists, I can check the Status property only for the service which exists)?
ServiceController controller = new ServiceController("not existing service");
try
{
if (controller.Status == ServiceControllerStatus.Running)
{
}
}
catch (InvalidOperationException ex)
{
}
}
thanks in advance,
George
|
|
|
|
|
You could use the ServiceController.GetServices() method to enumerate through all services and check if there is a service with a name that you're interested in. Or you could use WMI.
|
|
|
|
|
Thanks Zoltan!
Your solution works!
regards,
George
|
|
|
|