Hello! :)
i need to make something that change the image inside a picturebox every 1000 milisec for a 6 pictures (for example), so i search about a function that can hold the code for this time and i found Thread.Sleep(1000) (after use the "using.Threading" ofcourse)
so i put that function after each time the picturebox change the image inside it but something wierd happened...
when the program running and got to the part that it need to move between the 6 images with 1000 milisec between then it just do it fast and got to the last picture and then hold the time for 1000 X 6 milisec...

i guess its because its on another threads (for what i understand that threads are...)... i think... i dont know how to fix that

please help!
thanks :)

Unless you are multithreading, thread sleep is a poor way to time things. Use a timer control and in the tick event change your picture.

this is a good idea to use timer... i didnt knew this option is exist :)
but still...
if i need to make something like -

[piece of code]
[stop the code from continue for 1 sec]
[the rest of piece of code]

i can do the middle with some function?
in the timer solution i can call the event for somecode but the program will continue to run

i really need that to be that way - it means that i will must to do the threading thing? if so - where to start?

thanks in advance!

somebody? it means that nobody knows?...

When you put a thread to sleep, everything executing on that thread stops. So if you put the UI Thread to sleep, it won't update the form.

If you aren't using multi-threading, then you're effectively putting your entire application to sleep!

Timers can be set to execute at a set interval. They are run on a different thread (unless you're using one of the other timers, I forget which as I never use them)

I think you're looking at this from the wrong perspective. You seem to be looking at this from a what code do I want to *stop* running for a second. Whereas, you should be thinking, what code do I want to *start* every second.

Windows programming and C# in particular is very event driven. You should be using a timer to execute certain code every second, not stopping your application's execution for a second.

PS. When you start using Threads and Timers, you also need to start looking at "Invoke", "InvokeRequired" and "delegate methods".