Question: I'm running a CPU consuming process (calculate mandelbrot set) and that process takes almost 100% of the CPU (I have 8 cores on my machine). when I change the affinity to half of the cores the CPU consumption show 50% or lower and that is cool but what I want to understand is how this magic is done:

**my question:**
If I change the affinity while the process is running and there are threads on disabled cores - Is it safe that I won't lose any data? how is it done?

Answer: 
Although not specifically asked, I should point out (since I load all of my cores for weeks at a time, thus have some familiarity with this subject) that Affinity, while it can be useful, is not as important as Priority. Your jobs will generally finish twice as fast at 100%, compared to 50% CPU Utilization. Set the long running tasks to Low Priority and they will still run at 100% (as long as nothing of higher priority wants to run), but it will minimize the impact on doing other light-weight tasks. Only manage Affinity if there are fan noise/thermal issues you need to address... vacuuming my PC periodically gets me more mileage in that case.
There is absolutely, positively, **no** risk of loss of data (or of data corruption) here. Or of process termination or any other problem. The windows scheduler handles this situation tens or even hundreds of times every second. 

Changing process affinity (or changing its priority for that matter) - which really is changing the affinities (and priorities) of the process's threads - is just another reason for preemption. 

After preemption, a thread may run on a different logical processor than it did the last time it was running. That is a completely common occurrence.