|
If you are going to do something like that use:
foreach(Thread t in workerThread)
{
thread.Join();
}
I'd only do something like that in a simple console application and I didn't care about the results of the DoSomeWork method. Otherwise I'd use asyncronous delegates and callback methods.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
I have several threads, calling the same function.
This function does not access any global stuff... Only variables created inside it.
If I have something like this:
void foo()
{
int x = 100;
}
Is a new instance of x being instantiated for every call a thread makes?
Or is the same instance of x being used over and over...?
|
|
|
|
|
It is declared locally so every thread will have its own value.
|
|
|
|
|
Thank you very much...
I'm new to threading... And I have a bug in my program...
So I just wanted to make sure it's not the reason.
Thanks again...
|
|
|
|
|
Im getting "The Server is not operational" when authenticating user to active directory
Any help plzz...
Thanks in advance
Krishna
|
|
|
|
|
Hi,
I'm displaying a web page in a windows form. Now that the page is displayed, I want to be able to set the cursor to a specific position, and then move it until it reaches another location on the page. The second location has no ID, no name and that is why I'm approching the question like that.
I'm new to C#, so if anybody can help...
|
|
|
|
|
I couldn't realy understand...
Are you looking for a function which sets the cursors position?
If you are, you can use the SetCursorPos API function...
I doubt that there's any .NET implemented function to do this...
Best regards,
Shy
|
|
|
|
|
How would I add text to a listbox and have that text added to the top line instead of the bottom line?
|
|
|
|
|
try doing the same function you do but backwords.
i.e: insted of:
for (int i = 0; i < n; i++)
write:
for (int i = n-1; i => 0; i--)
or
for (int i = n; i > 0; i--)<br />
i-1;
etc...
another way is to use a DataSet to arrange the stuff up... (may be longer)
that's all I can think of (without looking at properties etc...)
yours, NaNg.
|
|
|
|
|
hi JMichael2468!
Instead of using the ListBox's Items.Add method, use the Items.Insert method.
then pass a zero value in the index parameter so it will be added on top of the collection.
i tried it and it works fine with me.
hope this helps!
microsoc
|
|
|
|
|
|
Hey all... I know a little C#, I've been working with it for 2 years (still at school, 11th grade), I'm pretty expirienced but still I don't know alot... I'm building all my programs on VC# express, which as you know, has built-in publisher, with built-in installation, well, I wanna do a few things out of the small box it shows me, so here are some questions that I remember now, that I would like answers to them, and appriciate if you would answer, or give me a link for it:
1. How can I register my program in such a way, that the computer will know that files with endings such as what I want(i.e .ysl) will have an icon that I want?
2. How can I register my program in such a way, that I can put an option of "Start with Windows startup"?
3. What is the BEST way to make sure that my program is only run ONCE in the computer, and that no-one will be able to open another copy will the first one is running?
4. How can I open a process (System.Diagnostics.Process), and make sure it's an internet explorer program, such as IE or NetScape no-matter to the program he use (IF statements will be accepted), and open it in a URL I want?
5. How can I tell who implements ICryptoTransform (System.Security.Cryptography.ICryptoTransform) without checking at Microsoft's MSDN for each and every one? and what is the best way to encode (Crypt) my code (what is the best ICryptoTransform implementing class to do it)?
6. Where can I find default icons such as SaveAs... (three discates), Save (one discate), open (folder), new (page) etc...?
well... that's enough for now... if I'll remember some more I will ask...
THANKS IN ADVANCE FOR ALL THE ANSWERS!!!!
-- modified at 15:51 Monday 8th May, 2006
|
|
|
|
|
sorry for the multiple posting, the site said and error and I thought it didn't post it, if the admin can erase one please, but leave one also, that would be lovely ...
thanks...
|
|
|
|
|
This happens from time to time.
You can erase your postings on your own. There is a delete link at the right side of bottom edge.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
3. Search for "single instance" here on Code Project. There are some articles covering this topic. (By the way this should be done everytime before asking a question in the forum).
1. I think there are articles too which cover this topic.
2. Where do you want to put this option? If you want to start your application with windows startup, simply create an appropriate link in the Autostart folder of startmenu.
4. Process.Start("www.troschuetz.de"); //Opens URL with standard browser
6. Not sure, but maybe searching for "*.ico" on C-partition brings some results. Also googling for "ico" or "icon" and "SaveAs", "Save" or ... may be worth a try.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
1. Create some registry entries under HKEY_CLASSES_ROOT:
This can all be done programatically, but it takes some work. Look at the Microsoft.Win32 namespace for registry manipulation functions.
1) Create a key by the name of the file extension you want
2) Set the default attribute of this key to a word that describes your program. It's name doesn't really matter.
3) Create a key by the name of the word you decided on in step 2.
4) Create some subkeys: 'DefaultIcon' and 'shell'
5) Set the default attribute of the DefaultIcon key to the path of your icon. If you want to use the the same icon
as your executable, do something like this: <code>c:\code\mysupercoolapp\exefile.exe,0</code>
6) Create a 'open' subkey under 'shell' and a 'command' subkey under open
7) Set the default attribute of the 'command' key to the path of your program (include the %1) <code>c:\code\mysupercoolapp\exefile.exe %1</code>
8) Restart
9) When a file with the extension you've picked is double-clicked, your application will run.
The first argument will be the path of the file.
2. You can put a link in the startup folder of the start menu, or add a registry entry to either
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
(if you want it to run whenever the computer starts)
or
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
(if you want it to run whenever only the current user logs on)
3. As the other post-er said, search for "single instance"
4. System.Diagnostics.Process.Start("http://www.myurl.com"); will open the url in the default web browser
5. I should read up on cryptography
6. They are in a zip file in Visual Studio's program folder:
C:\Program Files\Microsoft Visual Studio 8\Common7\VS2005ImageLibrary\VS2005ImageLibrary.zip
(or similar)
Hope this helps,
DigitalKing
|
|
|
|
|
thank you very very very very very very very very much!!!
Both of you!
|
|
|
|
|
the Process.Start("http://..."); method is opening the URL in the already opened browsers, how can I turn it to new browsers?
|
|
|
|
|
There's no good way to accomplish this, as it is the user's preference.
For example, in firefox, the user can select whether to load newly opened pages in the current tab, or a new tab.
|
|
|
|
|
Hey all... I know a little C#, I've been working with it for 2 years (still at school, 11th grade), I'm pretty expirienced but still I don't know alot... I'm building all my programs on VC# express, which as you know, has built-in publisher, with built-in installation, well, I wanna do a few things out of the small box it shows me, so here are some questions that I remember now, that I would like answers to them, and appriciate if you would answer, or give me a link for it:
1. How can I register my program in such a way, that the computer will know that files with endings such as what I want(i.e .ysl) will have an icon that I want?
2. How can I register my program in such a way, that I can put an option of "Start with Windows startup"?
3. What is the BEST way to make sure that my program is only run ONCE in the computer, and that no-one will be able to open another copy will the first one is running?
4. How can I open a process (System.Diagnostics.Process), and make sure it's an internet explorer program, such as IE or NetScape no-matter to the program he use (IF statements will be accepted), and open it in a URL I want?
5. How can I tell who implements ICryptoTransform (System.Security.Cryptography.ICryptoTransform) without checking at Microsoft's MSDN for each and every one? and what is the best way to encode (Crypt) my code (what is the best ICryptoTransform implementing class to do it)?
well... that's enough for now... if I'll remember some more I will ask...
THANKS IN ADVANCE FOR ALL THE ANSWERS!!!!
|
|
|
|
|
I have a need to take schemas of any kind and have generic code that will "walk" through the stuff and come up with the results that look similar to the XSL view in VS2005. While I don't need to create the graphic view....I do need to lump together each element, its' name, and the child nodes and attributes associated with that element. I loaded up a schema object and was able to see the first node, but walking deeper into it is a stumbling block right now. Any suggestions / articles would be appreciated.
-- modified at 15:06 Monday 8th May, 2006
|
|
|
|
|
I am using Asyncallback in .net CF development in a button_click event. There is no problem when I complie and deploy the program, but as I click the button to start the event, error occured. The message is 'An unhandled exception of type 'System.NotSupportedException' occurred in System.Windows.Forms.dll', and it stopped at 'application.run(new form())' I used the begininvoke to start the callback, and endinvoke to get the result. I used ppc 2003 emulator, and vs2005. Thanks for your help.
Here comes part of my code:
private delegate int CalcDelegate(int input1, int input2, ref string strResult);
CalcDelegate mDeleg;
private void button1_Click(object sender, System.EventArgs e)
{
mDeleg = new CalcDelegate(Calc);
int input1 = Convert.ToInt16(textBox1.Text);
int input2 = Convert.ToInt16(textBox2.Text);
string strResult = null; // dummy parameter
AsyncCallback cb = new AsyncCallback(CalcCallback);
IAsyncResult ar = mDeleg.BeginInvoke(input1, input2, ref strResult, cb, null);
Thread.Sleep(1000);
}
private void CalcCallback(IAsyncResult ar)
{
string result=null;
int output = mDeleg.EndInvoke(ref result, ar);
textBox3.Text = output.ToString();
}
|
|
|
|
|
This is not the first time I've seen this, either...
I create a RichTextBox, and I catch some keydown events. I want to catch CTRL-I, CTRL-B, and CTRL-U for changing selected text (italic, bold, and underline). It works fine with CTRL-B and CTRL-U, but when I hit CTRL-I, the richtextbox inserts tabs in there, too. For example (if you were to open the RTF files in Notepad), this line:
... bla bla bla ...
turns into:
... \i\tab bla bla bla \i0\tab ...
instead of:
... \i bla bla bla \i0 ...
And, if I do it right, it seems to replace the selected text with an italicized tab.
Any ideas?
-Daniel
-- modified at 14:25 Monday 8th May, 2006
|
|
|
|
|
I believe you want to catch the KeyDown or KeyPress event (not sure which one). One of these events lets you tell the event handler that you have processed the key and this prevents the underlying UI control from seeing it.
|
|
|
|
|
I currently am catching the KeyDown event. I'll see if setting the KeyEventArgs e.Handled to true helps at all...
-Daniel
|
|
|
|
|