Well, if it does, the code isn't really parallelizable. If each iteration of the for loop overwrites the variable in a way that is dependent on previous iterations, it doesn't really make sense to parellilize it. For example, if it really is calculation of primes, then numbers = 10000 could run before numbers = 2.
The problem you have is that you don't know the bounds of your input - you don't know how big number will have to get to generate the required number of primes.
However, you can still parellelise chunks of work - something like this:
constint N = ( int ) 1e6;
staticreadonlyint STEP = Environment.ProcessorCount * ( int ) 1e6;
var primes = new List<int>( N );
for ( int start = 2 ; primes.Count < N ; start += STEP )
Enumerable.Range( start, STEP )
.Where( i => IsPrime( i ) ) );
primes = primes.Take( N ).ToList();
You'll have to tune the values of N and STEP for your specific case.
Be excellent to each other
I am working on a small application that checks what browsers are installed on a system running Windows Xp... I was able to find the right entries to check whether Firefox and Chrome are installed or not... And after quite some amount of googling about IE, I found that IE might get corrupted due to some unforeseen reasons... So, is there a possibility of a windows system to have NO internet explorer installed? If yes, How can I check whether IE is present or not.. Please suggest...
IE is a part of Windows itself and you can safely assume its existence on Windows. I personally won't go bothering about an usecase where the IE installation is corrupt for some unforeseen reasons. It may be negligible.
It is a crappy thing, but it's life -^Carlo Pallini
Is there any way to get a XmlTextWriter to work with a MemoryStream, so that it doesn't close it when it is finished?
What I'm trying to do is:
List<T> -> MemoryStream (as XML) -> TripleDES encyrption -> file.
file -> TripleDES decryption -> MemoryStream -> List<T>
And since XmlTextWriter always closes the stream when it completes, the MemoryStream is useless!
Yes, XMLTextWriter has settings, but they are null or read-only, so you can't set "CloseOutput = false"
(No, I don't want to use XMLSerialiser, for very dull reasons!)
I have got round it by moving to XmlWriter and using the settings that way, but this was such a waste of time!
WriteXML(listCards, new XmlTextWriter(stream, Encoding.UTF8));
Does anyone know a way I could simulate 7.1 channel surround sound with DirectX? Our school is doing the Wizard of Oz as the school play this year, and as part of it, we want the tornado to move around the Audience, we have speakers in the right spots, and the everything we need to drive them, its just we need to be able to move the sounds around and make them feel realistic to the audience.
So in short, does anyone know how I could set up 7 listening devices in DirectSound or XNA so that the levels change for each speaker as the virtual speaker moves throughout the audience.
In the Device Manager, double click on your serial port to get to the settings form, then go to the "Port Settings" tab and click on the "Advanced..." button.
Here you can manually set the COM port number associated with your hardware. It usually won't update in the Device Manage list unless you unplug and plug the device again, but it will take effect immediately.
Hope this can help.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
when I pass the delete argument in command prompt a confirmation will appear. After pressing "y" it the schedule is deleted successfully.
I want to pass "y" as arguments but don't know how because I am already passing delete command in arguments
I am assuming SCHTASKS is a regular console application, that produces some output (a prompt) in the console or DOS window, and takes some input from there as well.
The easy solution, if provided, is by passing another switch; try "SCHTASKS -h" to see its help.
If no extra switches are available, you should be able to do it with standard stream redirection; have a look at the Process class, StandardInput/StandardOutput properties, and OutputDataReceived events. You probably need to redirect the output (so you can wait for the confirmation prompt to arrive), AND redirect the input stream, so you can writeline "Y" to it.
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.
Last Visit: 31-Dec-99 19:00 Last Update: 27-Jan-23 23:18