writing files in the Tick events when each write takes longer than the interval

A

AAaron123

I have a timer. At each tick, say 0.1 second, I write a file.

If it takes more than 0.1 second to write the file the app will not work
correctly.

How can I tell in the tick event if the previous file finished writing so I
can skip writing at that time?

I write using the Bitmap.Save method.

Maybe I could Open, Write, Close synchronously??

Any ideas?




What happens if the Click event takes more that 0.3 seconds to exit.

Do the click events pile up and then come right after each other or are the
past ones simply missed?


Thanks
 
R

rowe_newsgroups

I have a timer. At each tick, say 0.1 second, I write a file.

If it takes more than 0.1 second to write the file the app will not work
correctly.

How can I tell in the tick event if the previous file finished writing soI
can skip writing at that time?

I write using the Bitmap.Save method.

Maybe I could Open, Write, Close synchronously??

Any ideas?

What happens if  the Click event takes more that 0.3 seconds to exit.

Do the click events pile up and then come right after each other or are the
past ones simply missed?

Thanks

You need to find a solution that doesn't rely on time, otherwise you
will spend the rest of the project's life debugging race conditions.

Is it possible to use a message queue to track the writes? The tick
event would write to the queue, and then the the changes could be
written out from the queue asynchronously.

Also, why not just keep the bitmap in memory and write it to a file
when the changes are done?

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 
C

Cor Ligthert[MVP]

Aaron,

Why not do the writing of the file assynchronous in a backgroundworker.

The queue class will be a greath class to fullfil that.

Cor
 
A

AAaron123

Use a thread to write and check to see if the thread is still active??

Is that what you mean?


I'd have to learn how to do that but that would be a plus!

Thanks
 
G

Gillard

do you write new image or it is the same image??

AAaron123 said:
Use a thread to write and check to see if the thread is still active??

Is that what you mean?


I'd have to learn how to do that but that would be a plus!

Thanks
 
A

AAaron123

Not sure what you mean about the queue. I'd have to save the images and the
queue would write them?
Is that what you mean.

In my post I should have said: it is much like saving the frames of a movie.

Thanks


I have a timer. At each tick, say 0.1 second, I write a file.

If it takes more than 0.1 second to write the file the app will not work
correctly.

How can I tell in the tick event if the previous file finished writing so
I
can skip writing at that time?

I write using the Bitmap.Save method.

Maybe I could Open, Write, Close synchronously??

Any ideas?

What happens if the Click event takes more that 0.3 seconds to exit.

Do the click events pile up and then come right after each other or are
the
past ones simply missed?

Thanks

You need to find a solution that doesn't rely on time, otherwise you
will spend the rest of the project's life debugging race conditions.

Is it possible to use a message queue to track the writes? The tick
event would write to the queue, and then the the changes could be
written out from the queue asynchronously.





Also, why not just keep the bitmap in memory and write it to a file
when the changes are done?

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 
R

rowe_newsgroups

Not sure what you mean about the queue. I'd have to save the images and the
queue would write them?
Is that what you mean.

In my post I should have said: it is much like saving the frames of a movie.

Thanks












You need to find a solution that doesn't rely on time, otherwise you
will spend the rest of the project's life debugging race conditions.

Is it possible to use a message queue to track the writes? The tick
event would write to the queue, and then the the changes could be
written out from the queue asynchronously.

Also, why not just keep the bitmap in memory and write it to a file
when the changes are done?

Thanks,

Seth Rowe [MVP]http://sethrowe.blogspot.com/

At first take, yes you would need to save each bitmap into the queue
and then write them to files asynchronously.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 
A

AAaron123

thanks
Not sure what you mean about the queue. I'd have to save the images and
the
queue would write them?
Is that what you mean.

In my post I should have said: it is much like saving the frames of a
movie.

Thanks












You need to find a solution that doesn't rely on time, otherwise you
will spend the rest of the project's life debugging race conditions.

Is it possible to use a message queue to track the writes? The tick
event would write to the queue, and then the the changes could be
written out from the queue asynchronously.

Also, why not just keep the bitmap in memory and write it to a file
when the changes are done?

Thanks,

Seth Rowe [MVP]http://sethrowe.blogspot.com/

At first take, yes you would need to save each bitmap into the queue
and then write them to files asynchronously.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 
A

AAaron123

sorry, I should have said. A changing image but some may repeat. Missing
some is OK.

So should I use a thread to write and check to see if the thread is still
active and only write if it is not active?


Thanks
 
A

AAaron123

Well, now I've got to read up on backgroundworker message queue.


Thanks for the direction
 
A

AAaron123

My news reader must have it in for you.
Replies to others look OK.

Can't imagine what is going on!!!!


At first take, yes you would need to save each bitmap into the queue
and then write them to files asynchronously.

Thanks,

Seth Rowe [MVP]http://sethrowe.blogspot.com/

Also, please take a look at how your news reader does it's quoted
text, normally quoted lines have a '>' at the beginning, but yours are
missing. It makes it very hard to track conversations :)

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 
C

Cor Ligthert[MVP]

Aaron

It is not a message queue, it is simple a queue.
You enque it in the mainthread and deque it in the background worker in a
loop.
and then you write the map that was in the file (B aware that is only a
reference before you think that it takes memory)

You have to test if it becomes empty, and filled again, because then you
have to restart it again.
Don't forget to synclock it while enqueing and dequing

http://msdn.microsoft.com/en-us/library/system.collections.queue.aspx

Cor
 
A

AAaron123

I'm not sure I'm thinking about this correctly.

If I do a file save in the program every .1 of a second and the save only
takes .01 of a second to run, I think I still have a problem.

Doesn't the save hand off the file to the system to write? So if the system
takes more than .1 second to write the file my code could overwhelm the
system even though it sees no blockage.

Than sounds like a problem without a solution!

thanks
 
A

AAaron123

Thanks, please see my last post to this topic.
Cor Ligthert said:
Aaron

It is not a message queue, it is simple a queue.
You enque it in the mainthread and deque it in the background worker in a
loop.
and then you write the map that was in the file (B aware that is only a
reference before you think that it takes memory)

You have to test if it becomes empty, and filled again, because then you
have to restart it again.
Don't forget to synclock it while enqueing and dequing

http://msdn.microsoft.com/en-us/library/system.collections.queue.aspx

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top