|
Hi!
I am trying to create a simple example with the System.Timers.Timer, and i can not.
can someone show me where i need to declare in a win project this timer and how to use it(which event?how to declare it?)
I have searched the web but i get only complex examples and not the simple one, even in the MSDN.
Thanks 
|
|
|
|
|
Hi,
the timer classes on MSDN contain a simple example.
I have an article on timers, it comes with some test/demo code.
The easiest timer to use (in a Windows app) is a Windows.Forms.Timer (not the System.
Timers.Timer since that one ticks on another thread).
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Is it possible to specify the date and time of an outgoing System.Net.Mail.MailMessage?
|
|
|
|
|
The date/time to send the mail can ce stored in the property DeferredDeliveryTime . If DeferredDeliveryTime contains any value, the Exchange server will keep the mail in the outbox until the specified date/time.
____________________________________
There is no proof for this sentence.
|
|
|
|
|
I'v been making an app that communicates with my home pc from any other. One of the things it does is sends a message to my pc saying to delete a file or directory (and if its a file or directory its deleting)
Anyway, i tell it to delete a folder within My Documents (the folder was NOT empty, it had files and other folders within it)
So, my home pc calls
Directoty.Delete(path, true);
I have no idea what the hell happened, by all files and folders within my documents had been deleted. It should have come back with an exception because the folder was not empty right? How the hell did it get to the parent directory and start deleting everything?
|
|
|
|
|
Well, by passing a true to the Delete call, you are telling it to remove directories, subdirectories, and files in path. If you actually read the MSDN documentation on Directory.Delete(String, Boolean)[^], it says that an IOException will be thrown when dhe directory specified by path is read-only, or recursive is false and path is not an empty directory.
As to why it deleted starting at the wrong directory, how sure are you that the path you sent is actually the one that was received? Put some debugging statements in your client code and print out the path before actually performing the delete (or instead of it) to make sure it's working with the correct path.
|
|
|
|
|
I must have misread, i knew by using recursive it deleted subdirectories, but i thought they had to be empty of files.
But still, more care on my part in future, especially when dealing with delete()
|
|
|
|
|
It's easy to miss. You should always be careful when dealing with file or directory deletes. I worked with someone who managed to get a bug into production that under certain conditions would delete the entire C:\Users directory due to a bug in the recursion. (It was code that had been added and never code reviewed, but it shipped anyway and caused a huge headache.)
|
|
|
|
|
Scott Dorman wrote: It was code that had been added and never code reviewed, but it shipped anyway and caused a huge headache.
Sounds bad...
Just goes to show, code reviews can be a good thing :->
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Paul Conrad wrote: Sounds bad...
It was. It caused a lot of people to scramble to figure out ways to help the affected customers recover the deleted files. The worst part of it is that the developer is still at the company and didn't even get a reprimand.
Code reviews are always a good thing, but their effectiveness is limited by how seriously people take them.
|
|
|
|
|
Scott Dorman wrote: Code reviews are always a good thing, but their effectiveness is limited by how seriously people take them.
Very true. It does depend on how serious people take it. Seems more that often there is a rush to get things out into production and play blame game later.
"Try asking what you want to know, rather than asking a question whose answer you know." - Christian Graus
|
|
|
|
|
hi,i wanna get a certificate in C# that proves that i do know programming.
i need 2 know the books i need,the exam im gonna be taking,the exam questions,im planning a self study plan,so i need a lot of help,thx in advance
|
|
|
|
|
samymoenis wrote: wanna get a certificate in C# that proves that i do know programming.
Take a BrainBench certification if that's all your interested in. Seriously, having a certification doesn't prove that you know programming. Experience and past accomplishments prove you know programming. All the certification does is show that you have knowledge of a particular language and programming concepts.
If you want one of the Microsoft certifications, go to the Microsoft Learning[^] pages and look at the different certifications you can earn. There are different ones depending on what your development focus is. This will give you all of the information you need to know which exams you need to take and were to get study materials.
Seriously, the certifications should be about what you know not how hard you can study.
|
|
|
|
|
I wasn't sure if a Microsoft certification would be worth the time and effort. But it certainly was in my case. Certification did two things for me. First, it let me know that I understood the breadth of .NET programming. The second, it showed others.
Experience still matters. But certification did set me apart in job interviews. In fact, I think the interviews got easier because I had accomplished something that the interviewer hadn't done yet.
Not only that, but certifications provide partner points to the company that hires you. If they find two people that have a similar certifications, it can generally help move a company to Certified or Gold status. And that means licenses and benefits for a company. (Check out the competencies under the Partner Program tab inside the The Microsoft Partner[^] site.
I did a boot camp with NetCom[^] partly because it was tough for me to settle down each day.
I suggest putting together a plan for how you want to earn your certification. Check out Microsoft Learning[^] to put together what you need to know. Start out in an area that you are familiar with. Even one Microsoft certification exam will get you noticed as a Microsoft Certified Professional[^].
Check out the books that have MCPD (Microsoft Certified Professional Developer) or MCTS (Microsoft Certified Technology Specialist) in the title.
Study for one exam. Most of the books will have the exam number in the title too.
Here's the strategy I took. I learned the material both in class and by programming. In my opinion, the subjects are just too hard to just read and take the test. Once I had a handle on the material, I scheduled the test. This gave me a deadline to jump in and study. Next I spent a 10-hour day studying test questions and answers. I got like a 50% the first time though. And each time through the set of questions, I got better. By time I took the test I was able to answer nearly every one from memory. Then I passed the test. One with a score of just 700. Others in the 800-900 range. (You need 700 to pass.)
You can get sample questions on the web at sites like Transcender[^].
Best of luck in your studies.
-- bruce
Check out Innovate On[^] for information about emerging Microsoft technologies.
|
|
|
|
|
hi all
1) i want to know more difference between destructor and dispose method.
if u have any articles please let me know
2) Base b=new Derived()
derived d=new Base()
which one is illegal and why
i have found second question in a paper i could not get a answer for (oops concepts)
|
|
|
|
|
Since you are asking this in the C# forum, I'm going to assume you want to know specifically about C#.
kalyan_2416 wrote: 1) i want to know more difference between destructor and dispose method.
if u have any articles please let me know
First, take a look at this article[^]. It will give you an explanation of the IDisposable interface and the Dispose method.
C# does not have a destructor like C++ does. It does, however, have a finalizer which is defined using the same syntax as a C++ destructor, namely the ~T syntax (where T is the name of the class).
The Dispose method is described by the IDisposable interface and is used primarily when an object mantains unmanaged memory. It provides a way for the caller to explicitly indicate that it is done using that object and that it is safe to cleanup managed or unmanaged resources. Internally, the Dispose method knows how to cleanup those unmanaged resources. This is important because the GC in .NET doesn't know any thing about what to do with these unmanaged resources.
A finalizer is a "special" function that helps guarantee that the object will be properly cleaned up. That being said, there are very few times when you should implement a finalizer as there are a lot of specific rules that apply in order to get them right.
kalyan_2416 wrote: 2) Base b=new Derived()
derived d=new Base()
which one is illegal and why
Which one do you think is illegal? Have you tried to create this code in Visual Studio? If you think about what you are trying to accomplish with this bit of code and understand what the names mean it should become very clear. If you think of derivation as a tree structure, the child classes derive from the base class, with each child class becoming increasingly more specialized the further away from the base class they are.
|
|
|
|
|
oledbcommand cmd=new oledbcommand(@"select F1,F2,F3 from [sheet1$]",con);
F2 datatype string when execute command get F2 values Null
please i need why get F2 null
but if values integer can get data
|
|
|
|
|
You asked this same question in the SQL Forum, please do not cross post.
"Try asking what you want to know, rather than asking a question whose answer you know." - Christian Graus
|
|
|
|
|
just want automated e-mail which sends mails to another person.
i have created a console application which will log my current work and history activities at regular time.
so i extended my idea that console also can send mail to another person on a specified time,
eg: every three hours it sends a mail to another person. notice that as it mail it collects the logged contents from log file , but not as attachment, (person mail address is already specified in the code)
thanks and great for helping me.
so much of happy ending...
|
|
|
|
|
|
hi, thank you so much and for understanding. i'll go through this.
so much of happy ending...
|
|
|
|
|
Sorry, what is your question?
Me: Can you see the "up" arrow?
User:Errr...ummm....no.
Me: Can you see an arrow that points upwards?
User: Oh yes, I see it now!
-Excerpt from a support call taken by me, 08/31/2007
|
|
|
|
|
so here i have created a console application in c sharp which logs my activities done on documents and others.
i want add a new task on this console application. thats mail service as in my article.
my question here is is it possible to:
- mail should collect my logges contents and
- mail to someone automatically on regular time
i hope you understand. thanks
so much of happy ending...
|
|
|
|
|
well, i suppose to create a simple program which logs my history documents activities. but i seen it working only when i open console which should be run automatically and in background.
so i want consoler to run automatically and it should be hidden in background processing.
thanks and great for who help me right now.
so much of happy ending...
|
|
|
|
|
It should be possible to hide the console window using the function ShowWindow .
Add these lines of code before (or at least outside) the Main() method:
[System.Runtime.InteropServices.DllImport("user32.dll")]<br />
public static extern void ShowWindow(IntPtr hWnd, int nCmdShow);<br />
<br />
[System.Runtime.InteropServices.DllImport("user32.dll")]<br />
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
Then add these lines of code at the top in your Main method:
<br />
IntPtr hWnd = FindWindow("ConsoleWindowClass", null);
ShowWindow(hWnd, 0);
And that's it.
Edit: Yup, it works
Oh, I almost forgot. You wanted it to run automaticly. Just place the exe-file in the Start Menu\All programs\Start folder. Then it will be run everytime you log on to Windows.
-- modified at 5:38 Sunday 23rd September, 2007
Virtual1ty
--
"Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|