|
Where is your FileSystemWatcher object? I assume it's in a class you've written, correct?
Create a timer object as a field to this class. In your method that handles events from the FileSystemWatcher object, check to see if the timer is running. If not, you're receiving the event for the very first time: Start the timer. Else the timer is running. Stop the timer, do whatever you need to do, and restart it.
My impression is that your creating the timer in the event handler. You thus lose the reference to it after the handler completes. By making the timer a field of the class, it's accessible within the class for the lifetime of the instances of the class (objects). Make sense?
|
|
|
|
|
Yes indeed you are correct. The Timer is being creates in the Eventhandler. How do i create it as a field to this class? I knew that this was the problem but i don't see a way of checking if the timer is already running.
|
|
|
|
|
Ylno wrote: How do i create it as a field to this class?
There are several timers[^] to choose from in the .NET Framework. First, you'll need to choose which one is appropriate. If you're using a form, the System.Windows.Forms.Timer[^] may do the trick. You can just drop it onto your form in the designer or manually add it yourself to your class:
public class MyClass
{
private System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
}
To keep track of whether the timer is running, just check the timer's Enabled property:
public class MyClass
{
private System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
private void HandleSomeEvent(object sender, EventArgs e)
{
if(timer.Enabled)
{
timer.Enabled = false;
}
else
{
timer.Enabled = true;
}
}
}
|
|
|
|
|
When I use the Invalidate() method in my form in the OnPaint() method, all my form does it start flashing like crazy. All I need for the form to do is refresh itself.
-----
Note: *** Never give me an answer have anything to do with Visual Studio. I don't have this program, and it'll be that way for a long, long time. ***
|
|
|
|
|
Invalidate() forces a paint event. Which calls onPaint. Which, in your code, calls Invalidate.
You have no need to call invalidate in your paint event, the form is already invalidated, hence the fact that your paint code is running.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I need the OnPaint event to call repeatedely, over and over. That's why I put Invalidate() at the end of the OnPaint event. Is there another way to do this without the screen flashing?
-----
Note: *** Never give me an answer have anything to do with Visual Studio. I don't have this program, and it'll be that way for a long, long time. ***
|
|
|
|
|
max29297 wrote: I need the OnPaint event to call repeatedely, over and over. That's why I put Invalidate() at the end of the OnPaint event. Is there another way to do this without the screen flashing?
Use a timer event to periodically invalidate the form. If you can call the overloaded version of Invalidate that takes a Rectangle to invalidate only the portion of the form that needs repainting, you'll get more efficient results. Invalidate() causes the entire surface of the form to be repainted.
|
|
|
|
|
What is an example of a timer event?
-----
Note: *** Never give me an answer have anything to do with Visual Studio. I don't have this program, and it'll be that way for a long, long time. ***
|
|
|
|
|
max29297 wrote: What is an example of a timer event?
For a form, you could create a System.Windows.Forms.Timer[^] object. Hook up to its Tick event, set the Interval property to the desired polling time, start the timer, and finally in response to the Tick events, invalidate whatever portion of the form that needs to be repainted.
|
|
|
|
|
Thank you!
-----
Note: *** Never give me an answer have anything to do with Visual Studio. I don't have this program, and it'll be that way for a long, long time. ***
|
|
|
|
|
How is it going? I see you still haven't managed to get Visual Studio Express yet. I have to commend you on your persistence to develop without Visual Studio. You are learning a heck of a lot of good stuff that a lot of people would just walk past because Visual Studio does it all for them. Not enough people, in my opinion, take the time to learn what is actually going on. You are and that is great! It will mean that in the future when things go wrong you'll be able to think your way out of the situation much better than those people who learned while Visual Studio was hand holding them through everything.
|
|
|
|
|
hello ..I have the following problem
<Document>
<Employee>
<Name>John</Name>
<Class>A95</Class>
<ID>E5</ID>
</Employee>
<Employee>
<Name>Bill</Name>
<Class>B96</Class>
<ID>E4</ID>
</Employee>
<Employee>
<Name>John</Name>
<Class>A95</Class>
<ID>E5</ID>
</Employee>
</Document>
and I want for every Employee element to save it in html file
(Name of file depend on ID)
how can do it using c#.net
tkml123
|
|
|
|
|
Create a XSLT and transform the xml into anything you want.
only two letters away from being an asset
|
|
|
|
|
|
Hello everyone,
I was wondering if it is possible to change the SOUND when the DilagoBox pops up. Currently the sound that I am getting sounds like "DOMB". Is it possible to have something more elegent or customized?
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
Khoramdin wrote: I was wondering if it is possible to change the SOUND when the DilagoBox pops up.
You mean message box. The sound is linked to the sounds set up in the user's preference. You can change the messagebox's icon, which also changes the sound it makes. See the various overloads of MessageBox.Show[^]
If you want something completely different then you will have to write a (real) dialog box of your own.
|
|
|
|
|
Hi,
I am trying to make this work here, I set a form authentication on my site from a SQLDatabase. Now the membership tool did not seem to give me all I needed so I followed an example using tickets to specify user roles from the database. All in all it works well. The only problem I am having is that whenever I am authenticated with a lesser user role (let say Role 1) and I am trying to axs a page requiring Role 2 let's say, I am redirected to the login page - not the error page. I tried to find a trick to redirect to the error page all users already authenticated (meaning that most of the time it would be because they tried to axs a page to which they can't axs) but that means even if the user wants to go back to the login page he will be redirected to the error page, which doesn't make sense.
So my question is - Is there a variable or a way to know that a user tried to axs a restricted page even though he was already authenticated??
JC
PS: I hope it's clear, I seem to have difficulties putting it to words
|
|
|
|
|
If you want to redirect the user to error page, then raise a custom exception. And configure your web config file customError section to redirect to the required page.
Hope this gives you some insight of the solution am thinking of
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
|
|
|
|
|
I had thought of that but I couldn't find out where and how to raise the exception. In my mind the embedded role from <authorization> element already raises an exception to send to the login page...
So I guess I found a workaround - probably if I put the error page as my login page in the webconfig and then redirect if not autenticated it would work. Although I find it a bit sloppy and I cannot beleive there isn't a better way to do this ...
but thanks for the input
JC
|
|
|
|
|
Not a problem let me know in case if you find any other query, If I know then I will be happy to clarify.
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
http://jaiprakash.blog.com/
|
|
|
|
|
Hai everyone i am rohit pokhrel from nepal i am trying to develop a video/audio requesting system in c# in which users can request songs by pressing the key pad in the phone but the main problem i cant trap the key press event. Can anyone please help me.................
|
|
|
|
|
You are in the wrong forum, you need to be posting this in mobile development forum.
With a subject line like that, most of the people are going to ignore your post. Give a meaningful subject to get answers to your post.
Tarakeshwar Reddy
MCP, CCIE Q(R&S)
There are two kinds of people, those who do the work and those who take the credit. Try to be in the first group; there is less competition there. - Indira Gandhi
|
|
|
|
|
Atleast you looked after man its not problem of creating wap application or smart device application you i just want to implement mscomm control
|
|
|
|
|
hi
i want to add any exe file(s) to my app and extract it at on Hard drive at runTime ?
thanks
|
|
|
|
|
You can embed any binary data as a resource in the project. However, I am suspicious of a request to hide any executable code inside another assemby. It seems to me to be the first step on the road to creating a Trojan.
|
|
|
|