471,595 Members | 1,986 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 software developers and data experts.

How can I set affinity ofthe Word.Application object to one proces

Hi all,

We have noticed that using the Word OLE is much slower on dual processor
machines.
Limiting the processor affinity to one processor helps.
So, I want to set the affinity in my C# code.

I succeeded with the following code:
oWord = new Word.Application();
Process[] wordProcesses = Process.GetProcessesByName("WINWORD");
if (wordProcesses.Length == 1) {
(wordProcesses[0]).ProcessorAffinity = new IntPtr(1);
}

However, I only want to effect the WINWORD process I just created.
And not any others that might be running.
For now, I worked around this by seraching for the WINWORD process with the
latest timestamp. This works, but does not feel like great code.

Is there any way to get from an Word.Application object to its associated
process?
Can I get the ProcessID in some way?

Any help is appreciated,
Thanks,
Tony.
Oct 31 '06 #1
1 1795
You want to get the PID right? Here:
http://www.csharphelp.com/archives2/archive334.html

chanmm
"theTone" <th*****@discussions.microsoft.comwrote in message
news:21**********************************@microsof t.com...
Hi all,

We have noticed that using the Word OLE is much slower on dual processor
machines.
Limiting the processor affinity to one processor helps.
So, I want to set the affinity in my C# code.

I succeeded with the following code:
oWord = new Word.Application();
Process[] wordProcesses = Process.GetProcessesByName("WINWORD");
if (wordProcesses.Length == 1) {
(wordProcesses[0]).ProcessorAffinity = new IntPtr(1);
}

However, I only want to effect the WINWORD process I just created.
And not any others that might be running.
For now, I worked around this by seraching for the WINWORD process with
the
latest timestamp. This works, but does not feel like great code.

Is there any way to get from an Word.Application object to its associated
process?
Can I get the ProcessID in some way?

Any help is appreciated,
Thanks,
Tony.


Nov 1 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by sudha | last post: by
4 posts views Thread by Daniel | last post: by
1 post views Thread by =?Utf-8?B?VmlqYXkgQ2hpa3Rl?= | last post: by
reply views Thread by Armen Kirakosyan | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.