|
Hello,
I try for :
Object oMissing = System.Reflection.Missing.Value;
Object oTrue = true;
Object oFalse = false;
Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document oWordDoc = new Microsoft.Office.Interop.Word.Document();
oWord.Visible = true;
oWord.Visible = false;
Object oTemplatePath = @".\1.doc";
oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);
foreach (Microsoft.Office.Interop.Word.Range range in oWordDoc.Words)
{
if (range.Text.Trim().Contains("P"))
{
int pos = range.Text.Trim().IndexOf("P");
string str = range.Text.Trim().Replace("P", "");
range.Text = str;
}
}
Directory.CreateDirectory(@"F:\PS-IN\"+threadContext);
Object oSaveAsFile = @"F:\PS-IN\" + threadContext+"\\" + threadContext + ".doc";
oWordDoc.SaveAs(ref oSaveAsFile, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing);
Console.WriteLine(threadContext+" "+DateTime.Now.ToShortTimeString());
oWordDoc.Close(ref oFalse, ref oMissing, ref oMissing);
oWord.Quit(ref oMissing, ref oMissing, ref oMissing);
}
static void Main(string[] args)
{
const int FibonacciCalculations = 50;
ManualResetEvent[] doneEvents = new ManualResetEvent[FibonacciCalculations];
Program[] fibArray = new Program[FibonacciCalculations];
Random r = new Random();
Console.WriteLine("launching {0} tasks...", FibonacciCalculations);
for (int i = 0; i < FibonacciCalculations; i++)
{
doneEvents[i] = new ManualResetEvent(false);
Program f = new Program();
fibArray[i] = f;
ThreadPool.QueueUserWorkItem(f.TEST,i);
}
WaitHandle.WaitAll(doneEvents);
Console.WriteLine("All calculations are complete.");
}
it generate the 50 word files, but he never leaves the wait, thank you for your help.
|
|
|
|
|
Do you ever set doneEvents members to true? If not, how can you expect the wait to ever succeed?
Please think about what you're doing before posting a code dump here. If you don't understand how threading and wait handles work, please read up on them before trying to use them.
|
|
|
|
|
i find the solution, we must add doneEvents[int.Parse(threadContext.ToString())].Set(); after the and of generation.
modified on Tuesday, May 17, 2011 5:05 AM
|
|
|
|
|
I need to pass parameters (like arraylist,...) to the TEST method, how i can do this ?
I don't understand whay the test methode must have juste the object parameters.
modified on Tuesday, May 17, 2011 5:45 AM
|
|
|
|
|
hi all.
I divide width of row datagridview in c# .
when i set columnHeaderVisible = true: OK
but i set columnHeaderVisible = false: it have been wrong 1 desert = width of row header.
question : when set columnHeaderVisible = false. how i do to width of rows in datagrid not wrong ???
please help me.
code
dataGridView.Height = h*12;
dataGridView.RowTemplate.Height = h;
if dataGridView.columnHeaderVisible = true ==> ok
but : dataGridView.columnHeaderVisible = false ==> not ok
nothing
|
|
|
|
|
Hi,
Okay, I read your question a couple of times, and I have no idea what you just said / asked? Could you please try and be more specific about the problem?
Kind regards,
|
|
|
|
|
You're going to have to define what a correct column width should be for anyone to answer this.
What do you mean by "not wrong"??
|
|
|
|
|
Hi,
How to find out installed MS office 2010 is 32-bit or 64-bit from the registry?
googled and fouind couple of links...but seems not working or do not have the registry key.
thanks.
|
|
|
|
|
Hi,
Have a look at the following key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Outlook] -> Bitness=x86
Kind regards,
|
|
|
|
|
I also got the same when I googled it.This registry key is not there in my machine.
|
|
|
|
|
Hmm....
What type of OS are you using?
You can always check in your program files. If Outlook was installed in the 'Program Files (x86)', when it should be 32-bit otherwise it's a 64-bit installation?
|
|
|
|
|
Although this is the general case, the user may have installed the app in a custom folder - and this check will fail.
@OP: If the OS is x64 there should be HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node node and under it, if there's an Office x86 product install, there should be a HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot Key with a Path value set. (substitute "14.0" with the appropriate version.)
If it's x64 bit version, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot Key should be present.
2A
|
|
|
|
|
|
I posted my answer here.
I hope this helps.
2A
|
|
|
|
|
Hello,
I wanted to create an application in which I wanted to start my application at specific time, say I wanted to start my application at every 3 PM. If my computer is not on at 3 PM, I must be able to start it on later time as well.
I am using C#.Net.
Happy Programming.
|
|
|
|
|
According to this message[^] you are using C++/MFC. Please do not post the same question in multiple forums.
The best things in life are not things.
|
|
|
|
|
Busted ...
|
|
|
|
|
Task scheduler in Windows?
I cannot remember: What did I before google?
|
|
|
|
|
I am talking about adding my Task to Control Panel -> Scheduled Tasks.
|
|
|
|
|
|
i create report rdlc and pass to it datasource ana add it in Microsoft report viewer
and on this report i add image from toolbox i need to pass image from DB in this image box
|
|
|
|
|
|
Hello CP,
Really unsure whether or not to post this here or with SQL.
I'm currently working with C# and Sql Server 2005 Express.
I've got two tables:
<br />
_Cases_<br />
CaseID, (PK, Identity (+1 increment))<br />
ClientID (FK)<br />
Description,<br />
DateRegistered,<br />
etc<br />
<br />
_Tasks_<br />
TaskID (PK, Identity (+1 increment))<br />
CaseID (FK)<br />
CompanyCost<br />
ClientCost<br />
As you can see, tasks depend on a case.
My form contains a lot of info for the Case and a small datagridview for the tasks.
I save my case and wish to add tasks to it.
Problem is that I don't know what CaseID the case has gotten.
I can query for Max(CaseID) possibly with a DateTime in the 'where' clause.
Although my method works, I was wondering if someone has a better idea, preferably in C# code.
|
|
|
|
|
Your problem is to get last inserted caseID or selected caseID from gridview?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
You can't rely on the Max, or (necesarily) the datetime. If you do get two close-to-simultaneous updates, then there is a very good chance that the dates will be the same anyway.
Instead, do not rely on the database to ensure unique ID's - change the Id field type to Guid, and assign them yourself, before you insert the new record to the table. Advantages: you never have to search for the record you just inserted to find out the ID because you knew it before you inserted it. If you put a try-catch block round the insert, you can handle the (extremely unlikely1) event that you do get a duplicate and assign a new Guid for a retry.
I stopped using int IDs except for log entries a few years ago, and use Guid nearly exclusively.
If you must use DB assigned ints, then you can get round the problem using a stored proceedure to insert the record and return the ID, using IDENT_CURRENT: MSDN[^]
1 You are more likely to win the lottery every draw for the rest of your life than to get two matching Guids, in theory!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|