|
you lazy little *&^@!
use google[^]
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
musefan wrote: you lazy little *&^@!
lol! +5
|
|
|
|
|
Hi,
both subroutines and functions are called methods in C#; they may or may not return one value or reference, depending on the return type in the declaration. Same as in C, C++, Java, and a lot of other languages (except they often are called functions, with or without a return value).
I suggest you buy and study a tutorial on C# so you can reach structured and illustrated knowledge in minimal time.
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.
|
|
|
|
|
Seriously, this is a C# 101 class question. Pickup a beginners book on C# and work through it. It'll answer just about all of your basic questions like this.
|
|
|
|
|
Epic fail. How can you be asking about events first and only after that want to return values? Obviously something is wrong here. I think you're some gold member who thinks it's funny to ask crazy questions on purpose. And if that's true, well, ok it would be funny I suppose.
|
|
|
|
|
I have searched high and low for an answer to this one. I'm sure someone has
run into a similar situation.
Basically, I set up a serial port with a ReadTimeout of 10 seconds; open it; send a "command"
character to a serially attached device and expect an answer within this period of time.
If data is received, the serialPort_DataReceived event handler fires and reads the data.
However, I want to be able to notify the operator of a problem, should the external
device not reply within 10 seconds. This could indicate the device is not attached or
not powered up.
Appreciate the help,
Steve.
|
|
|
|
|
thompsons wrote: I have searched high and low
Not high and low enough then. It took me 10 seconds to find this[^]
The SerialPort class provides a timeout mechanism on its Read methods. When the read timeout is exceeded, a TimeoutException gets thrown.
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.
|
|
|
|
|
Thanks for the reply. I also found that; it did not directly answer my question.
This implies that I need to make a call to serialPort.ReadLine() before any notification occurs in the case of a timeout. One of the reasons folks join these forums is because they want answers in plain English and not the somewhat vague documentation offered on MSDN.
Sorry I asked such a silly question that caused your sarcasm to manifest itself.
Regards,
Steven.
|
|
|
|
|
The quality of the question directly dictates the quality of the answer.
If you don't start a read operation, you're not going to get a notification that anything showed up. What if your code isn't ready to recieve yet, but there's pending data? That's why it works this way.
|
|
|
|
|
So you want to get an event because data that you did not request did not arrive in time?
That is not how Windows (or any other OS I am aware of) works. You can get an event when something unexpected happens (e.g. DataReceived, ErrorReceived) or you can get an Exception when something you did order did not succeed for some reason.
If you are not satisfied by the DataReceived events (and I can imagine several scenarios where it is insufficient), then you must create your own thread and have that perform synchronous read operations, with or without timeout.
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.
|
|
|
|
|
My normal way to do SerialPort uses an AutoResetEvent to do the timeout control. The general format is something like this:
dim port as SerialPort
dim ReceiveResponse as AutoResetEvent
Sub SendCommand(data() as Byte)
sendTries = 0
while sendTries <= MaxTries
sendTries += 1
port.Write(data)
if ReceiveResponse.Wait
'you got a response
else
'you didn't get a response in time
end if
end while
End Sub
sub PortDataReceivedHandler(sender as object, e as DataReceivedEventArgs)
if processIncomingData() then
ReceiveResponse.Set()
end
end sub
Obviously, this is missing a lot of actual code, but it should point you in the right direction.
|
|
|
|
|
I'm upgrading an app from 1.1 to 3.5, and my googlefu is failing to tell me anything about what was changed between the two classes except that it happened in 2.0.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
By my understanding, its appearances. MSDN says that there are additional features, but I can't find anything going into detail
|
|
|
|
|
Menustrips can have comboboxes and textboxes as children.
|
|
|
|
|
Thanks to both of you. The appearance change is annoying. I'm adding DataGridView 's which only work with the new menus, but for visual consistency reasons I'm going to have to update the rest of my menus as well.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
Hi,
I'm writing an application where I want to play a MP3 based URL with Windows Media Player. I have searched long and hard and I can't find a good example of what I want to do. I have come up with this code, but nothing happens. I must be missing something, any ideas, examples or thoughts are greatly appreciated.
WMPLib.WindowsMediaPlayerClass w = new WMPLib.WindowsMediaPlayerClass();
AxWMPLib.AxWindowsMediaPlayer Player = new AxWMPLib.AxWindowsMediaPlayer();
w.URL = "http://myurl.com";
w.enabled = true;
w.play( );
Thank you,
Glenn
modified on Friday, May 22, 2009 10:48 AM
|
|
|
|
|
Why not use the simple:
System.Diagnostics.Process.Start(@"c:\XXTemp\Track01.mp3");
Has the advantage that it uses the users prefered media player, too.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
That would work with a URL as well like this:
System.Diagnostics.Process.Start(@"http://www.myurl.com");
However I need to pre-load the MP3 from the Internet and a timer will click play at the exact instant the MP3 is supposed to be played. This is for broadcasting automation, so timing is critical.
Glenn
|
|
|
|
|
If timing is that critical, then why are you relying on an external service?
Build an MP3 player into your app, so you have decent control over it.
Google is your friend here![^]
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi,
I'm picking up the hourly 5 minute newscast from Fox. The radio station software switches over to live input at the top of the hour and picks up the audio from the MP3 player. If I knew how to download the newscast, I could play it from the hard drive.
I have an application that is not working so well that picks up the audio feed. It uses QuartzMediaPlayer. It used to work perfect until a couple of weeks ago. Now it just plays the same newscast over and over again from the Internet. If I were to play it off the hard drive, that would be better. WMP seems to work correctly every hour by hand.
Glenn
|
|
|
|
|
If I have a class which holds a bunch of employees and I want to allow enumeration over it, I can implement IEnumerable as below:
public class EmployeeCollection : IEnumerable<Employee>
{
private List<Employee> _employees;
public IEnumerator<Employee> GetEnumerator()
{
return this._sheets.GetEnumerator();
}
public IEnumerator GetEnumerator()
{
return this._sheets.GetEnumerator();
}
}
Any idea how I can allow enumeration if I am using a Dictionary<string, Employee> instead of List<Employee>? What interface do I need to implement and how?
CodingYoshi
Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
|
|
|
|
|
You could probably return this._sheets.Values.GetEnumerator() .
|
|
|
|
|
The problem I was having was that I did not know what interface to implement if I am storing items internally as a dictionary.
I simply implemented IEnumerable<keyValuePair<string, Employee>> and that did it.
CodingYoshi
Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
|
|
|
|
|
Hey all,
Got an interesting problem where I'm using a cascaded combobox type setup, with the second combobox's IntegralHeight property set to true so that it should resize itself relative to the contents of the items list.
However, it's not doing this and I'm stumped. I don't think I should have to go ownerdraw in order for this to work, so can anyone suggest a reason why it might not be working?
FYI I am rebinding the combobox datasource to a datatable each time the "master" combobox value changes.
|
|
|
|
|
If you set the DropDownHeight property, this resets the IntegralHeight to false. Make sure you have not done so.
CodingYoshi
Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
|
|
|
|