Thanks much. That seems to work. I was just confused about how SetData and GetData worked apparently.
bradsnobar
Posts
-
Store data that is private to a thread using the thread object. -
Store data that is private to a thread using the thread object.Hello, How do I save data to the current thread. I want it to be accessible only to the current thread. I need to be able to store data specific to a thread without being able to have control over the object that a thread is executing on. This is because most of the control is handed off to the runtime, so I can't just add it to an object that is created and used to launch my own thread. I've found a method that looks promising: System.Threading.Thread.SetData System.Threading.Thread.GetData The problem is that it takes a slot as a parameter and I won't be able to use the same slot name across all the calls to set and get data or the data will just get overwritten by other threads. I want to store authentication information here. So, it needs to be unique for each thread. (In case you are wondering... I can't use the CurrentPrinicple object for my auth.) Also, the data can be shared across all of the threads with the slots and that is also bad because authentication information shouldn't be shared like that. Any ideas will be a great help. Thanks!!!
-
What cpu is my thread executing on?I've worked around my problem for now with a well placed thread.sleep for now. Thread affinity looks like the right path to take though. Thanks for the advice.
-
What cpu is my thread executing on?Hello, I need to throttle a running thread based on the cpu usage that the thread is currently using. My main problem is that my machine has 4 cpu's and I don't know how to figure out which cpu my thread is executing on. (The other cpu's will be used for other queued thread work items, so I can't just look at total cpu usage.) My goal is to poll for cpu usage > 60 % on the current thread and then call thread.sleep until cpu usage returns below that level. I assume that I'll need to use a performance counter to do this. int processorInstance = 'need to figure out what to set this to.' System.Diagnostics.PerformanceCounter c = new System.Diagnostics.PerformanceCounter("Processor", "% Processor Time", processorInstance.ToString()); Thanks, Brad
-
how to get holding key down to repeat an actionI found the snippet to handle an arrow key being repeated in a winform control. The ProcessCmdKey method must be overriden to trap that key and the repeat message. Normally the keypress event is the one that allows repeat keypresses by holding the key down. (This rate of repeat is controlled by the bios and the OS) The keypress event does not trap the arrow keys. protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { const int WM_KEYDOWN = 256; const int WM_CHAR = 258; const int WM_KEYUP = 257; const int WM_SYSKEYDOWN = 260; const int WM_SYSKEYUP = 261; if (FromHandle(msg.HWnd) == this) { switch (msg.Msg) { case WM_KEYDOWN: switch (keyData) { case Keys.Down: int tag = (int)msg.LParam; bool repeat = (tag & (1 << 30)) != 0; if (repeat == true) System.Diagnostics.Debug.WriteLine("********************"); if (this.SelectedIndex + 1 >= this.menuItems.Count) this.SelectedIndex = 0; else this.SelectedIndex++;
-
how to get holding key down to repeat an actionsorry, that's not correct in this case.
-
how to get holding key down to repeat an actionsorry, that's not correct in this case.
-
store procedure vs hard coding sql statementsThe difference in performance is typically large. Use the sql stored procedures instead. If they can see your stored procs then they can see your data too. So which is more valuable? Probably your data. This is a seperate problem that can be addressed with a good amount of security. There are typically three layers of security... IIS --> SQL --> Windows (File System) Sometimes the SQL auth is integrated so SQL and file system are the same. Your choice. But, I choose seperated for higher security, and integrated for ease of use.
-
how to get holding key down to repeat an actionI want to be able to hold the down arrow key to continue to scroll on a custom control that I've written. How do I check for a key being held down? Is there a property or something to let a keydown event repeat itself?
-
Stop Button from taking focus during a keypress or keyup event.I found it... here is the magic override... protected override bool IsInputKey(Keys key) { switch (key) { case Keys.Up: case Keys.Down: case Keys.Right: case Keys.Left: return true; } return base.IsInputKey(key); }
-
Stop Button from taking focus during a keypress or keyup event.I wrote a custom menu control that accepts keyboard movement. I have a form with a button on it. When I click the button I see my menu pop up below the button. The problem is that the focus shifts between the button and the custom control whenever I press an arrow key. How do I keep other controls from stealing focus away from my custom control. I don't want to disable other controls. I want to maintain focus in my custom control I've tried to set the handled and the suppressKeyPress functionality in the event but the button still grabs focus for every other keypress. Any ideas? Thanks, Brad
-
Should I have outlook in order to show mht file in my c# application?You might check for the existence of the file Inetcomm.dll I found mine in C:\WINDOWS\system32\ string path = "%SystemRoot%\system32\Intercomm.dll"; path = System.Environment.ExpandEnvironmentVariables(path); bool isExist = System.IO.File.Exist(path); A better way might be to try to load the outlook object as a com object though. Then, if someone decides that library should get merged into another library, or decides to change the filename, or decides that dolphins should rule the earth, then you will still be golden if someone was smart enough to leave the functionality somewhere that the com object can get to it.
-
Messagebox pop up behind mainformI have a custom control that I has embedded controls. When I show a messagebox, the messagebox shows up behind the form. Topmost on the form is set to false. OpenFileDialog works as it is supposed to, why not messagebox? Any ideas? private void button13_Click_1(object sender, EventArgs e) { item i = new item(); Button b = new Button(); b.Text = "hello"; b.Click += new EventHandler(b_Click); subItem s = new subItem("hello"); s.EmbeddedControl = b; i.SubItems.Add(s); this.myListView1.Items.Add(i); } void b_Click(object sender, EventArgs e) { //using (OpenFileDialog dlg = new OpenFileDialog()) //{ // dlg.ShowDialog(this); //} MessageBox.Show(this, "hello"); }
-
Please help. MessageBox.Show(this, "hello") pops up behind my mainformtopmost is false
-
Please help. MessageBox.Show(this, "hello") pops up behind my mainformtopmost is false
-
Please help. MessageBox.Show(this, "hello") pops up behind my mainformHas anyone encountered a message box that pops up behind the main form? How do I fix this? private void button13_Click_1(object sender, EventArgs e) { item i = new item(); Button b = new Button(); b.Text = "hello"; b.Click += new EventHandler(b_Click); subItem s = new subItem("hello"); s.EmbeddedControl = b; i.SubItems.Add(s); this.myListView1.Items.Add(i); //my custom windows control } void b_Click(object sender, EventArgs e) { MessageBox.Show(this, "hello"); //this is refering to the main form in here... }
-
Network System.Net.Dns.GetHostByAddress is too slowHello, I have an app that I use to get poll for the hostnames on my local network. I use this method to get the information. System.Net.IPHostEntry hostEntry = System.Net.Dns.GetHostByAddress(address); The problem is that when GetHostByAddress(...) fails because there is no machine at a given IP address, it throws an exception that takes a long time (a few seconds). Is there a faster method to call? Is there a method that does the same thing, but sets an error value instead of throws an exception when a bad thing occurs? Is there some kind of timeout setting that I can set to like 20 milliseconds? (I can be assured of always being on a lan with a fast response) I use a whole bunch of threads to speed up the application, which makes the wait more tolerable, but it still takes way too long for my taste. Is there a better method to use in .Net 2.0 Thanks.
-
How To add VS.Net Design Time support for custom controlDo you know of a link that is for design time support for a regular windows control? The methods that are overrided in that ASP.NET example don't seem to have a counterpart from to override for normal winforms programming. Thanks, Brad
-
How To add VS.Net Design Time support for custom controlI made simple SideBar menu like Outlook has and I want to add design time support inside of VS.Net to drag controls onto it the various menu choices. Can someone please post a link to an article that has added design time support to a custom user control? Thanks.
-
Error: "Call was rejected by callee"Here is a hack workaround. So, go ahead and skip this reply if you want a clean solution. In my experience I've found that Excell/Access/Word Macros are basically hack jobs anyway, so it probably won't hurt much hacking it up some more. Can you modify the macro that runs when the file is opened every time that you run that code? Alternatively modify the macro to check for a condition that you set to exit immdediately. Example: Step 1.) Modify or remove problem macro Step 2.) Run your code Step 3.) Restore problem macro Step 4.) Possibly run problem macro