469,649 Members | 1,637 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,649 developers. It's quick & easy.

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

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


Aug 1 '08 #1
16 1261
On Aug 1, 9:33*am, "AAaron123" <aaaron...@roadrunner.comwrote:
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/
Aug 1 '08 #2
what about thread?

"AAaron123" <aa*******@roadrunner.comwrote in message
news:e0**************@TK2MSFTNGP02.phx.gbl...
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

Aug 1 '08 #3
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

"AAaron123" <aa*******@roadrunner.comschreef in bericht
news:e0**************@TK2MSFTNGP02.phx.gbl...
>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

Aug 1 '08 #4
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

"Gillard" <gillard_georges@@@@@@@@@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
what about thread?

"AAaron123" <aa*******@roadrunner.comwrote in message
news:e0**************@TK2MSFTNGP02.phx.gbl...
>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


Aug 1 '08 #5
do you write new image or it is the same image??

"AAaron123" <aa*******@roadrunner.comwrote in message
news:#6**************@TK2MSFTNGP04.phx.gbl...
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

"Gillard" <gillard_georges@@@@@@@@@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>what about thread?

"AAaron123" <aa*******@roadrunner.comwrote in message
news:e0**************@TK2MSFTNGP02.phx.gbl...
>>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


Aug 1 '08 #6

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
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:c9**********************************@26g2000h sk.googlegroups.com...
On Aug 1, 9:33 am, "AAaron123" <aaaron...@roadrunner.comwrote:
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/
Aug 1 '08 #7
On Aug 1, 9:55*am, "AAaron123" <aaaron...@roadrunner.comwrote:
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

"rowe_newsgroups" <rowe_em...@yahoo.comwrote in message

news:c9**********************************@26g2000h sk.googlegroups.com...
On Aug 1, 9:33 am, "AAaron123" <aaaron...@roadrunner.comwrote:
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/
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/
Aug 1 '08 #8
thanks
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:50**********************************@8g2000hs e.googlegroups.com...
On Aug 1, 9:55 am, "AAaron123" <aaaron...@roadrunner.comwrote:
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

"rowe_newsgroups" <rowe_em...@yahoo.comwrote in message

news:c9**********************************@26g2000h sk.googlegroups.com...
On Aug 1, 9:33 am, "AAaron123" <aaaron...@roadrunner.comwrote:
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/
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/
Aug 1 '08 #9
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

"Gillard" <gillard_georges@@@@@@@@@hotmail.comwrote in message
news:Od**************@TK2MSFTNGP02.phx.gbl...
do you write new image or it is the same image??

"AAaron123" <aa*******@roadrunner.comwrote in message
news:#6**************@TK2MSFTNGP04.phx.gbl...
>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

"Gillard" <gillard_georges@@@@@@@@@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>what about thread?

"AAaron123" <aa*******@roadrunner.comwrote in message
news:e0**************@TK2MSFTNGP02.phx.gbl...
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



Aug 1 '08 #10
On Aug 1, 2:52*pm, "AAaron123" <aaaron...@roadrunner.comwrote:
thanks"rowe_newsgroups" <rowe_em...@yahoo.comwrote in message

news:50**********************************@8g2000hs e.googlegroups.com...
On Aug 1, 9:55 am, "AAaron123" <aaaron...@roadrunner.comwrote:
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
"rowe_newsgroups" <rowe_em...@yahoo.comwrote in message
news:c9**********************************@26g2000h sk.googlegroups.com...
On Aug 1, 9:33 am, "AAaron123" <aaaron...@roadrunner.comwrote:
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/

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/
Aug 1 '08 #11
Well, now I've got to read up on backgroundworker message queue.
Thanks for the direction

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:86**********************************@microsof t.com...
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

"AAaron123" <aa*******@roadrunner.comschreef in bericht
news:e0**************@TK2MSFTNGP02.phx.gbl...
>>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


Aug 1 '08 #12
My news reader must have it in for you.
Replies to others look OK.

Can't imagine what is going on!!!!
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:92**********************************@f36g2000 hsa.googlegroups.com...
On Aug 1, 2:52 pm, "AAaron123" <aaaron...@roadrunner.comwrote:
thanks"rowe_newsgroups" <rowe_em...@yahoo.comwrote in message

news:50**********************************@8g2000hs e.googlegroups.com...
On Aug 1, 9:55 am, "AAaron123" <aaaron...@roadrunner.comwrote:
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
"rowe_newsgroups" <rowe_em...@yahoo.comwrote in message
news:c9**********************************@26g2000h sk.googlegroups.com...
On Aug 1, 9:33 am, "AAaron123" <aaaron...@roadrunner.comwrote:
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/

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/
Aug 1 '08 #13
My news reader must have it in for you.
Replies to others look OK.
LOL - just noticed that all other replies show up fine. Silly
newsreader and their vendetta's against me :-)

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Aug 1 '08 #14
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/libr...ons.queue.aspx

Cor
"AAaron123" <aa*******@roadrunner.comschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
Well, now I've got to read up on backgroundworker message queue.
Thanks for the direction

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:86**********************************@microsof t.com...
>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

"AAaron123" <aa*******@roadrunner.comschreef in bericht
news:e0**************@TK2MSFTNGP02.phx.gbl...
>>>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


Aug 2 '08 #15
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

"AAaron123" <aa*******@roadrunner.comwrote in message
news:e0**************@TK2MSFTNGP02.phx.gbl...
>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


Aug 2 '08 #16
Thanks, please see my last post to this topic.
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:0E**********************************@microsof t.com...
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/libr...ons.queue.aspx

Cor
"AAaron123" <aa*******@roadrunner.comschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
>Well, now I've got to read up on backgroundworker message queue.
Thanks for the direction

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:86**********************************@microso ft.com...
>>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

"AAaron123" <aa*******@roadrunner.comschreef in bericht
news:e0**************@TK2MSFTNGP02.phx.gbl...
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




Aug 2 '08 #17

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by elziko | last post: by
9 posts views Thread by Brett | last post: by
1 post views Thread by Philip Wagenaar | last post: by
16 posts views Thread by anonymous.user0 | last post: by
5 posts views Thread by Daniel | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.