|
Read the WAV file into a MemoryStream, and create a SoundPlayer, passing the MemoryStream as an argument. Then, just call Play
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Hi All
I use C#.Net To Create Windows Application system
I want to save the problems resulting from the system in the Right Click On
My Computer-> Manage -> Event Viewer -> Application Error
How can I do this
Thanks
Thaer
modified on Sunday, June 7, 2009 8:15 AM
|
|
|
|
|
using System.Diagnostics;
EventLog ApplicationEventLog = new System.Diagnostics.EventLog();
ApplicationEventLog.Source = "My application name here";
ApplicationEventLog.WriteEntry("My message here", EventLogEntryType.Error);
You should have a look at the docs for EventLog , you will see you can specify many more options.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
Hello Experts!!
I am taking linklabel from toolbox and i want to set internet explorer to that link thr' which i can show my organisation site.Dont knw what to do??
Help me!
|
|
|
|
|
Hi,
LinkLabel has a LinkClicked event; use Process.Start(myURL) to launch default browser, or Process.Start("iexporer.exe", myUrl) to launch Internet Explorer. There must be some documentation somewhere that contains all the details...
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.
|
|
|
|
|
Thanx for reply.....but what is MyURL....in my code it gives error->MyURL does not exist in current context
|
|
|
|
|
string myUrl = "http://www.mycompanysite.com";
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
In my examples MyURL is a string holding the URL you want to browse, I thought that was obvious. You can get it from the LinkLabel itself or store it as a string literal in your code.
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.
|
|
|
|
|
Hi
Is it possible to do some code X times e.g.
messagebox.show("Hello");
Thanks
|
|
|
|
|
Ummm, maybe I'm being dense and not really understanding your question, but what's wrong with a for loop?
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
jammmie999 wrote: Hi
Is it possible to do some code X times e.g.
//10 times
messagebox.show("Hello");
Simply Use Loop.
|
|
|
|
|
It's obvious you know nothing about programming, yet. So, buy a book before you ask the most elementary questions here. Knowing what a messagebox is, before knowing about basic constructs, will only create holes in your knowledge that you may never adequately fill. Do a course, or buy a basic book and read all of it.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
MessageBox.Show("Hello");
MessageBox.Show("Hello");
MessageBox.Show("Hello");
MessageBox.Show("Hello");
MessageBox.Show("Hello");
MessageBox.Show("Hello");
MessageBox.Show("Hello");
MessageBox.Show("Hello");
MessageBox.Show("Hello");
MessageBox.Show("Hello");
Seriously; look at a for-loop
for(int i = 0; i < UpperBound; i++)
{
}
If there's only one action, then you can drop the { and }
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Uhm, dah, uhm whats UpperBound and why do you have a double ++ after i
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
these are just minor typos; anyway you're better of with an OK-Cancel kind of interface so the user can chose the number of greetings he gets.
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.
|
|
|
|
|
Hi,
If you have already used MessageBox.Show, then I am quite sure that you have also used the for loop.
Either you love IT or leave IT...
|
|
|
|
|
Hello,
i have a simple Client/Server Application. You know, to read data or Accept TCPClients (in TCPListener) i need some loops which waits for data or for incoming connections.
My Problem now... i have not a lot of Connections now (since now), but i have a CPU Usage of 99% when i start my applications. So i decided to put into the loops a "Thread.Sleep(100)" Command. But that doesn't help very well... And if i let my threads sleep for maybe 300 milliseconds, i get exceptions, because the client couldn't create a connection or i get exceptions because the TCPClient "isn't available"...
So, how do i can here avoid these huge CPU Usage... i mean, other server-applications and client-applications really doesn't need all my CPU Power
Many Thanks
|
|
|
|
|
Not sure I quite get what you're doing here. Usually you have one thread which just listens and accepts incoming connections - this thread is asleep until something comes in so doesn't use up any CPU bandwidth.
When a connection does come in, its usually passed to a new thread which handles it. These threads sleep as well when there is no network activity.
Regards,
Rob Philpott.
|
|
|
|
|
Well i don't mean network usage... i mean the CPU usage...
here for example one loop...
all my loops looks like that and so i don't understand, why i have such an CPU usage...
void connectionHolder()
{
while (cancel == false)
{
if (connection.GetStream().DataAvailable == true)
{
int maxBuffer = connection.ReceiveBufferSize;
Byte[] buffer = new Byte[maxBuffer];
int x = connection.GetStream().Read(buffer, 0, maxBuffer);
doAction(buffer);
}
Thread.Sleep(100);
}
}
|
|
|
|
|
Hi,
IMO you are wasting a lot of resources:
- what made you chose 100msec as your sampling period?
- why do you call connection.GetStream() every 100 msec?
- why do you call connection.ReceiveBufferSize every 100 msec?
- why do you allocate a new byte[] every 100 msec? can't you reuse it?
- why don't you use an event-driven mechanism, as provided by BeginRead (ignoring DataAvailable)?
softwarejaeger wrote: all my loops looks like that
and why do you need that many loops?
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.
|
|
|
|
|
Ok, some questions i really don't understand... :P
To you questions:
What made you choose 100msec as your sampling period?
Well a too long time, could give me a timeOut...
To question 2-4...
is there another way to do this? search for example for "TCP Client Server Tutorial c#" you'll find a lot of tutorials which works like this.
To question 5...
I didn't know that this is possible... have you an example for me? How the code should looks like?
To you question "why so many loops"
Well one for Listening for accepting connections and for each connection a Thread to get and process the incoming data...
|
|
|
|
|
Normally a server runs 1 thread to initiate client sessions, and 1 thread for each active client.
All of these threads perform blocking reads, so they are entirely event-driven, without the need of a polling loop, which is what your code is having.
FWIW: I think you're not ready to create decent server code; learn a programming language, object orientation, threading, and then create a client/server configuration.
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 that i told you one thread for listening connections,one for each connection for read/write/process data..
Wow..i shouldn't be able to create a client/server app?you talking to me like to a "newbie". Do we know us,that youre able to say something like that?
Sry i develop big applications with OoP! And a lot of clients, a few servers (which are running great,because they don't need to run asyc. Thats my first project which runs async and so i asked you how to solve that and you give such an answer? Well buts nothing suprising anymore, i knew a lot of developer with them you cannot talk normally, with them you're onl able to argue with...
So to something positive... Event-driven,i didnt knew that this is Possible with TCPClient. Great,the first test and it works fine. Now i can port it to my server.
Kind regards
|
|
|
|
|
So it works great now on the server
In 10 Minutes it was all developed, easier that i thought, i only had to change 5 lines or so, because i had a method in there i process my data.
|
|
|
|
|
No offense but it looks like you got that code by continuously evolving it until it worked.
The reason you are using CPU power for "nothing" is that you check DataAvailable. If you just read the bytes that you want it will wait anyway (if you use blocking reads you should set the socket.Blocking )
As it is now, it will continue to wait around 100ms (but sleep doesn't guarantee much) even if data is already available, which can't be good for the throughput.
This does mean, however, that you can't read "as much data as the other side has sent". The other side has to explicitly tell you how much it is going to send. I've never seen a stream based protocol that didn't do that though.
|
|
|
|