|
Hi! You have seen programs like TeamViewer. How can I monitor the desktop of another computer and send the information to a client using C#. How can I film the desktop and send it like a stream video?
Can you give some directions on what approach to take?
Still learning...
|
|
|
|
|
|
nike_arh wrote: Still learning clueless...
Fixed a minor inaccuracy for you.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I've done one in C++, it won't be very hard to so in C# as well. As you seem to be clueless from your previous posts, may be your should hire someone else to do it for you.
In case you wondering my charges are $500/hr it may take me around 6 weeks to complete ( so you are looking $500 * 40 * 6)
|
|
|
|
|
|
Thats 240 000 cans of coke (in my country)
|
|
|
|
|
only
|
|
|
|
|
Im using a SerialPort in order to connect a client and a server through modem.
I write some AT commands in the servers' modem buffer, and the client makes the handshaking correctly. The AT commands are written when the DataReceived Handler is triggered.
The problem is that when handshaking finishes and communication is established, I cant use the handler to detect new data , I have to do a loop, reading the serialport input buffer constantly. Is there a way to trigger the event handler and read data instead of using a loop?
Any help would be apreciated and excuse my english if I made a mistake
Ivan
|
|
|
|
|
I often use serial ports and other similar way of communicating to instruments and devices, and personally I prefer to write a thread for reading incoming data.
You can have the thread loop and check on incoming data and if any, read it all up (or up to a maximum of "n" bytes), and insert a Thread.Sleep(1) in the loop or similar to avoid using up all the CPU time.
You can use events to break the thread on closing the serial port and cleaning up, or even a simple boolean.
You must of course use some locking to ensure thread-safe access to the serial port object.
I've been using this technique for quite a few years, and it works quite nice IMO.
Hope this can help, if you need it I can give you some code snippets, just let me know.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
Thanks for your suggestion Moreno!
Yeah, I think thats the best way to do this task, but...
Im using GUI to report and show the status of each serialport (Im using 60 instances of it, I have 60 COM ports). For example, report if CD is on, CTS, if its reading, writing and so on... so I would have to make 60 threads for each serialport, plus main thread which manages all the GUI stuff, so I think I would have to use some sort of thread cross communication, and I'm not good at that topic . However, I'm googling that.
BTW if someone have any good resource about threads communication (sharing data between them), it would be very useful.
Thanks!
Ivan
|
|
|
|
|
I understand your doubts: threading can be a pain if you're not used to it, but it pays off.
My best suggestions is you create a wrapper class which includes all the serial port functionality, for example:
using System.IO.Ports;
internal class MySerialPortClass
{
...
private SerialPort MySerialPort = null;
...
internal void Open()
...
internal void Close()
....
internal void Send(string Message)
}
The class will also contain your thread and start/stop it automatically, for example upon creation/distruction or upon opening/closing the serial port.
To handle thread-safety you can simply use locking on the serial port object every time you access it, since that's the only shared resource. For example:
internal class MySerialPortClass
{
private object MySerialPortLock = new object();
...
internal void Open()
{
...
lock (MySerialPortLock)
{
MySerialPort.Open()
}
...
}
...
}
And the same technique must be used on any other property in your class that will be accessed by the read thread. For example, if you store the communication results in some variable and then access it from other threads, then you must use locking on it.
Finally, you can set up events for anything you want notification about. End of communications by either reading the answer from the device or timing out is the basic event you will need, but you can also add others depending on your needs. For example:
internal class MySerialPortClass
{
internal delegate void CommEndDelegate(string Result);
internal delegare void CommErrorDelegate(string ErrorMessage);
internal event CommEndDelegate OnCommEnd;
internal event CommErrorDelegate OnCommError;
...
private void DoOnCommEnd(string Result)
{
if (OnCommEnd != null) OnCommEnd(Result);
}
...
private void DoOnCommError(string ErrorMessage)
{
if (OnCommError != null) OnCommError(ErrorMessage);
}
...
internal void MyReadThreadRoutine()
{
...
DoOnCommEnd(Result);
...
DoOnCommError("Timeout");
...
}
...
}
This will make it easy to link the class to your GUI.
It's just a raw example, but I hope this will help you. Good luck!
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
This is really useful. Thanks a lot Moreno!, I'll try this...
|
|
|
|
|
Hello,
I use sql connection to show data in datagrids.
I want to put progress bar that will show the progress of the connection itself (from the opening of the connection, throught the collecting of the data with the queries and to the closing of the connection).
How can i do it?
|
|
|
|
|
Don't think you can the way you want.
I think the best you will be able to achieve is to report a progress value in between each step of the sql stuff, i.e.
report progress
open connection
report progress
run command
report progress
close connection
report progress
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
No, it won't be a good thing to do it. Because much of the time takes for the connection itself and retrieving the data (the query)
|
|
|
|
|
Yes, I know that's where the time is mostly spent. But like I said, you cant get the progress of either the connection or the query so my suggestion is about the best you can get.
What you have to consider is that to calculate a progress bar correctly you need to know the total value (i.e. total time, total length of data etc.). When you are doing things that require a network connection then many things can cause the connection to speed up or slow down thus making it impossible to get a precise total time. Of Course, Microsoft could have implement some guestimate functionality or something to do with the data being Sent/Received but AFAIK they didn't and the best you can do is wait for the connection to return a result.
Personal, in your instance, I would use a continuous style for the progress bar, then when the data is pulled of either set the bar to 100% complete, or show the progress of whatever you do with each row pulled back from the data.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
There is no way to show the real progress. All you can do is to work with asynchronous methods (BeginExecuteNonQuery[^] , BeginExecuteReader[^]) and show a marquee style progress bar. Stop the progress bar when you get the notification that asynchronous method is finished.
|
|
|
|
|
Or run the query in a different thread while you show a progressbar whose value is incremented every second using a timer.
You can set the bar's max value to the approximate number of seconds your query will take on average.
That's how most apps behave when they can't know the time an operation will take.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
Moreno Airoldi wrote: a progressbar whose value is incremented every second
That is actually called a "let us hope the other thread is still working on this, however I am not really sure any progress is being made, all I know is the clock is ticking"-bar.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Exactly hehe!
But seriously, if you implement a timeout check (and you MUST do that when you use this kind of worker threads), this solution works just fine.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
Like Navaneeth has said, there is no way of knowing how long the connection will take, sometimes it takes a split second so showing a progressbar for that is a bit overkill I would say. As for the collection of the data I would impliment a Marquee style progressBar. This will just scroll untill you stop it when the data has been retreived from the DB.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
yeah i'd do what musefan said, that's the approach i took when i wanted a thorough report for the connection/collection of the data
|
|
|
|
|
Hey all
I have created a setup of my application now my requirement is to run another setup when my application's setup is completed as it wont allow me to run setup during installtion of my application dats why i can't add any thing in commit custom action.
I've spent 3 days to search anything but coudn't find any if you guys have any idea how to do that please tell me.
Thanx in advance
|
|
|
|
|
if you want to run an executable from code you could use...
System.Diagnostics.Process.Start("MyEXE.exe");
Now I have helped you, maybe you could come knocking at my door a little later than scheduled?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
i think you didn't get it the problem is i wanna add a custom action that should run after the installation of my set up is completed i know how to run an exe or setup from code it just dont allow you to run any setup during the installation of you application.
|
|
|
|