I’m using PLINQ to run a function that tests serial ports to determine if they’re a GPS device.
Some serial ports immediately are found to be a valid GPS. In this case, I want the first one to complete the test to be the one returned. I don’t want to wait for the rest of the results.
Can I do this with PLINQ, or do I have to schedule a batch of tasks and wait for one to return?
Upon further review, you can apparently just use
FirstOrDefaultto solve this. PLINQ will not preserve ordering by default, and with an unbuffered query, will return immediately.http://msdn.microsoft.com/en-us/library/dd460677.aspx