|
Write an extension method that overloads the string.Contains() method.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Hi
I need to play(render) a video stream from an IP camera. Since media element does not support rtsp protocol, I created a rtsp client which connects to the camera. Now I am not sure what to do with that stream? My best guess is to save it file, and than use media player to render it. Does anybody knows how to do that? What I am concerned is, when to delete old data from the file and how can the same file be opened for reading and writing at the same time? If anybody has any ideas how to solve those problems, please let me know.
Uroš
|
|
|
|
|
|
That app. just downloads a jpeg and renders it - in my case I access a 3GP encoded file.
|
|
|
|
|
Hi
In my c# windows application I have a registration form having dropdown of Country, State and City fields.
I want to fill these dropdown from web as I don't want to fill them from database or any hard coded values. Is there any web service which provide the Country, State and City related updates or Is there any other way to Implement this?
Please Help..
Thanks in advance
|
|
|
|
|
|
I also found this link but here I didn't found the way to get City an states corresponding to that country.
I know I can also get list of all country using culture info in c#. But still unable to get list of state or city.
|
|
|
|
|
Don't; they'd be too long. Simply allow the user to type the input and then validate it. Drp down and such are for when you have a very few, lengthy, entries.
|
|
|
|
|
hi all,
i develop a windows application in c#, and i want to add an own button in controlbox (close,minimize,maximize) buttons, and override the window menu (right click on window bar show a menu contain the controlbox buttons as menu).
can i create an own button and override the menu for the window using c#, and how to do that??
thanks all.
|
|
|
|
|
It depends on what your target OS is. A solution that works on XP may not necessarily work in Vista/Win 7, but there's a question with some answers here[^] that might just help.
|
|
|
|
|
All,
I have a console application that's not mine; it cannot be modified. After starting it with a bunch of command line parameters, it computes something and displays the result on it's console. I would like to get the PARTIAL output and then kill it.
I have found several code examples that seemed promising. My problem is that I can't seem to read any output before the program is finished and I need partial output to decide to kill it, since it will compute much more that I don't need after the initial computations.
Jan C. de Graaf
|
|
|
|
|
I am assumming you are talking about a console program that runs from a command window?
If so the open a second command window. In the first command window,start the program and pipe output to a text file, and in the other command window do a type command on the text file with a more option pipe. As the file fills up you can scan it at your own reading pace.
|
|
|
|
|
Thank for your quick response!
I can run the console program from a command window yes.
>> with a more option pipe
What is a "more option pipe" ? Is this like 'tail' in most unixes? Can you give an example please.
I was hoping to use C# and the Process class and the RedirectStandardOutput option. But ran into the problem I described in my original question.
Jan.
|
|
|
|
|
when done correctly, one can get data from both the output and the error stream of a running app.
using Stream.ReadToEnd() would not be part of the correct way; using an extra thread would.
So maybe you should show a relevant snippet of your code for people to comment on.
|
|
|
|
|
I will post some code this evening when I continue experimenting at home.
I already tried using the available events on the Process class but those didn't fire untill the console application was finished.
I will try a background thread this evening and see how far I get.
Thanks.
|
|
|
|
|
The code below will display "Started!" in the textbox immediately. Next it will hit the TimerCallBack method every second after the initial 5 seconds of computation. As it is supposed to. Saidly Peek() return -1 up to the moment the console program finishes I know for sure output has already been written!
If I test the same from a command window, adding " > output.log" to the command line, the output goes into output.log but not untill the program finishes
If I start the program normally from a command window, output is written to the console line-by-line!
using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private Process process;
private void Form1_Load(object sender, EventArgs e)
{
process = new Process();
process.StartInfo.FileName = @"D:\Users\Jan C. de Graaf\Documents\Othello\test\zebra.exe";
process.StartInfo.Arguments = "-b 0 -h 24 -l 28 30 30 28 30 30 -r 0 -slack 0.0 -learn 26 22 -private -log hqbook.txt -test";
process.StartInfo.WorkingDirectory = @"D:\Users\Jan C. de Graaf\Documents\Othello\test";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
new System.Threading.Timer(new System.Threading.TimerCallback(TimerCallback), null, 5000, 1000);
textBox1.Text = "Started!\r\n";
}
void TimerCallback(object state)
{
while (process.StandardOutput.Peek() > -1)
{
var data = process.StandardOutput.ReadLine();
textBox1.Invoke((MethodInvoker)delegate{textBox1.Text += data + "\r\n";});
}
}
}
}
|
|
|
|
|
So you're saying that attempt failed. There are maybe a dozen more ways to do things. I suggest you dedicate a thread (could be a BGW); that way you don't need a timer, don't need Peek at all, you just do a blocking ReadLine in a loop, until the main thread decides all is done. I did this, all the way back, using .NET 1.0 and Windows 98, and I can assure you there have been some bugs in .NET 1.x making it pretty hard; Since NT/XP the code got simpler and it now runs like a charm, one thread for stdout, one for stderr, and their output intertwines as it would in a DOS window (Command Prompt).
Here is a typical receiver thread (the output() method is likely to contain a Control.Invoke):
private void stdoutReader(object dummy) {
for (; threadsRunning && stdoutLines<maxLines; stdoutLines++) {
string s=stdout.ReadLine();
if (s==null) break;
output(s);
}
stdoutDone=true;
}
Mind you, there is some buffering going on, in the target app and in your app, so don't expect the output right away, there will be say some delays, but not seconds, and certainly not till the target app finishes. And the DOS prompt/command window (or something deep inside Windows) is smart enough to adapt the buffering depending on how things get used, so a pipe may well have a larger buffer than a direct interactive invocation.
Due to the buffering and sometimes automatic but delayed flushing, determining the end of the output may be a little tricky too; here is one possibility (code executed in the main thread):
proc.WaitForExit();
for (; ; ) {
if (stdoutDone&&stderrDone) break;
int cur=stdoutLines+stderrLines;
Thread.Sleep(500);
if (cur>=stdoutLines+stderrLines) break;
}
threadsRunning=false;
|
|
|
|
|
Thanks for your tips. Still no luck. Code based on your clear tips below. I must admit that I didn't expect this to work since it is essentially the same as my previous attempt.
In my previou spost I mentioned that while running the console program from a command window displayed output neatly; every now and then a line of text. When adding " > output.log" to the command line, all output winds up in output.log but NOT UNTILL the console program finishes! So here we have the same behaviour as in my c# program! Perhaps the cause is the fact that this is not a native windows console program; it need cygwin1.dll to work. Might this cause the strange behaviour?
using System;
using System.Diagnostics;
using System.Windows.Forms;
using System.Threading;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private Process process;
private void Form1_Load(object sender, EventArgs e)
{
process = new Process();
process.StartInfo.FileName = @"D:\Users\Jan C. de Graaf\Documents\Othello\test\zebra.exe";
process.StartInfo.Arguments = "-b 0 -h 24 -l 28 30 30 28 30 30 -r 0 -slack 0.0 -learn 26 22 -private -log hqbook.txt -test";
process.StartInfo.WorkingDirectory = @"D:\Users\Jan C. de Graaf\Documents\Othello\test";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
var thread = new Thread(new ThreadStart(GetOutputAndDisplay));
thread.Start();
textBox1.Text = "Started!\r\n";
}
void GetOutputAndDisplay()
{
string output;
do
{
output = process.StandardOutput.ReadLine();
textBox1.Invoke((MethodInvoker)delegate { textBox1.Text += output + "\r\n"; });
}
while (output != null);
}
}
}
|
|
|
|
|
jancg wrote: t need cygwin1.dll to work. Might this cause the strange behaviour?
Absolutely. It tells me your target app is essentially a kind of Unix/Linux thingy, and CYGWIN has to do god knows what to make it behave (a bit) under Windows.
There still might be a solution, however I don't know it; I'm unfamiliar with the CYGWIN + .NET combination.
If the app is related to www.zebra.com by chance, you might ask them; they just might have run into this before and hold a solution.
|
|
|
|
|
|
|
Please don't crosspost. You already asked the same question in the Q&A section.
|
|
|
|
|
Hi Dears,
I wish to design Typing Tutor software, I need your help, Kindly let me know that,
How may I start and what are related methods and example, if you have or know.\
Thank you
(Riaz)
|
|
|
|
|
Whilst this isn't a terribly complex bit of software to write it is sufficiently complicated for us not to be able to provide you with an answer. What you want this to do, you need to figure out for youself, we can't and won't do this for you. This forum is for programming questions, you are askng for analysis.
To Start I'd say, you need to figure out a basic process to teach typing (videos needed? user metrics(WPM/Accuracy) at the very least a control that allows the learner to type text and checks for errors, speed etc, ), then start to implement that. You also need to figure out how much time and effort you can/want to put into this, and change the quantity/comprehensiveness of features accordingly.
Finally, as a peice of advice, don't start a question with "Hello Dears", to most of the English-speaking world it is similar to saying "Hello my darlings". I realise it's common to address people this way in India & Pakistan ( and the Middle East, but in Arabic/Farsi) but outside these area it sounds effete. Ask around in the General Indian Topics[^] forum for the cross-cultural woes they've had.
|
|
|
|
|
hello how do i get the color value in an array and append it to a panel showing its actual color as well as display r, g and b color value in a textbox?
|
|
|
|