I want to transmit a live video from server to multi clients using UDP, I m working in C# and I've captured the video from WebCam. So please tell me the steps to be follow to accomplish this task.OR if u have any tutorials or links related to my task plz Notify me.
Is it possible to change the screen resolution in c# (no DirectX!).
Also why is it that when creating a windows application in c# without the designer, along with your window you get a cmd window? Could someone post some code to get a simple window up without this!
I have a dataset containing multiple rows. Now I want to insert these rows at a stretch to database. Even though I'm using dataadapter.Update method, it's not updating or inserting any rows. Also, it is not giving me any error.
Anybody who knows please help. It's very urgent. Any url or link explaining the solution is also fine.
Hy there, I have a big problem(at least for me). I am trying to make some Controls that update themselves wery fast (even at 5 ms). It is for a game engine, but I want the users to make their game in the Form designer, this is why I derived the sprite from PictureBox.
My problem is that I will never be able to update the control from a separate thread (I mean i can but it's suicide) and from what I know every property\method call to a control translates to a SEND_MESSAGE or a POST_MESSAGE and this is processed in the UI thread. This is were all the other windows messages are processed, so when I start the update, the message queue gets filled with this updates and I'm not able to process other messages (resize, move window etc.). If I add an Application.DoEvents to the update, than the speed of the sprite will depend on what I am doing with the mouse\keyboard on the screen.
Can anyone help me with this problem?? I REALLY wan't to use controls for this game, but I am stuck Thank you
If you want to update a control from another thread than the owning thread for that control use Invoke or BeginInvoke to have the owning thread execute the update of the control.
On a side note, to me it sounds like you have a much bigger problem than this. You mention that the message queue of the UI thread gets filled and doesn't respond to other messages anymore. That sounds like you're just processing you're whole engine in a tight loop causing the CPU load to go to 100%. I don't think it would matter much which thread is handling the messages since the controls need to be updated somehow.
It could also be that you're UI thread is just waiting for something else causing it to freeze (and not respond to any messages).
Well, this is exactly my problem, Invoke or BeginInvoke will not help me, because they will just make a safe-thread call, but the update will still be made on the UI thread. I think I need a way to make the update from another thread, but in a safe way. Let me tell you some details of my engine.
For now, my Sprite control is derived from PictureBox, adding some animation support, like interval and an OnUpdate event that it's set by the developer. For now, my Form only has an Threading.Timer thread that at 5 ms() calls a method for every sprite on the form, to make the Sprite check if the interval has passed, and to call the onupdate event. If I let the OnUpdate event empty, my app works fine, since it has nothing to add to the message queue. But if I add something to the event (for example I added an Opacity property to the Sprite and in the event, I say Opacity+=5), I'm not able to do much while the sprite is running, because the message queue is filled with this messages sent by the Sprite.
I'm starting to think that making a game engine from the designer its a bad ideea, but it would be so easy for the developer to visually set the Sprites behavior. Thank you
And what if you update the Opacity once every 10 calls to OnUpdate giving you 20 updates a second in stead of 200? I can imagine that trying to change the opacity of a control 200 times a second might be a bit much. And I don't think you would see much difference anyway. My screen doesn't refresh itself at 200Hz the last time I checked.
I understand that, but imagine that a game doesn't have only one Sprite, I could add for ex 10 Sprites. What do i do then? I really wan't to make this game engine visually(like Flash). I think that my problem is that I need to set priorities to the messages sent to the message queue, for example the
click\resize\move etc.. , I mean all the messages that are sent by windows to the Form to be processed
before the control messages. Do you have any ideea how I can do that in C#? something like override WndProc or make my own custom message queue??
I can't help you with setting priorities to messages. But I doubt you're going the right course with that anyway.
I think another solution would be to use timeSetEvent/timeKillEvent as mentioned by Luc and just use one for each control. But don't have it fire off periodically unless needed. So if you're sprite is idle, don't fire off any timers. If you're sprite is moving, have a timer tick at a reasonable interval until you're sprite is done moving. This way no unnecessary events will need to be processed.
I'm not sure how windows likes it if you have a massif amount of sprites with timers, but I guess you don't need to worry about that right now.
Another solution might be to have one timer (again with a reasonable interval), which basically is you refresh all event. On that event you can check the position and shape of all controls and redraw them in one go. This will probably generate quite some messages at that time, but probably a lot less compared to having a tick every 5ms.
You can ask a timer to tick every 5 msec, that does not mean it will do that. Read my
If you use a Windows.Forms.Timer you will get ticks on the UI thread automatically,
saving half of the messages and avoiding the need for an explicit Invoke()
PictureBox is not my favorite Control, it has limited functionality and unknown overhead.
I guess your painting action is too expensive; I would suggest to optimise the paint
action, possibly by reducing the number of controls. In general the lightweight approach
gives the maximum performance, in its extreme form it means ypu use one Control (a Panel),
do all keyboard/mouse event dispatching yourself, and organize the paint event yourself,
carefully watching the invalidate region. IMO just adding lots of Controls is not the right
way to create a game.
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
i have 3 seesons in my database ,Morning Evening, And Afternoon.they are checkboxin database means YES/NO...........I have a datagrid inthat i have a field like Session
In session column i want to retrieve data from database according to the data in DB.
if morning and evening is checked it shows like MORNING,EVENING
Please help me regarding this issue?