User Profile
Collapse
-
Oh boy, good thing you sorted this out for me. This can become an issue when threading :) -
c# Threading: How to manage stacking calls
I have a timer T that launches an event on each tick:
Code:void t_Tick(object sender, EventArgs e) { System.Threading.Thread TickThread = new System.Threading.Thread(OnTick); TickThread.Start(); }
...Code:private void OnTick() { lock (this) { System.Threading.Thread.Sleep(10000);//in -
I'm sorry for my ignorance but what is the difference between these two snippets with regards to c.
andCode:car some_other_car = new car(); car c = new car(); c = some_other_car;
?Code:car some_other_car = new car(); car c = some_other_car;
Leave a comment:
-
c# Does casting create a new object?
I have a little dilemma I would like to straighten out.
I have a class Car with 100's of parameters.
I add a bunch of Car instances to a listbox. They are now plain old objects.
Then when I selected an item from the listbox, I would like to cast the object back to Car and print the parameters on screen.
so I have 2 options:
option 1:
...Code:Textbox1.Text = ((Car) Listbox1.SelectedItem).param1.ToString();
-
I think you can try something like this. The filter uses LDAP and you can't replace it with a regex:
(|(name=Zen*)(n ame= Zen*)))Leave a comment:
-
Intersting question:
I created a little test bench and you will need to do what the above post says: when you hide the form, all the controls get their visible property set to false.
...Code:private void button1_Click(object sender, EventArgs e) { if (label1.Visible == true) { label1.Visible = false; } elseLeave a comment:
-
There is a very good free Microsoft tool named LogParser 2.2 here:
http://www.microsoft.com/downloads/d...displaylang=en
Read the help file, it has all the examples, commands and useful information you will need. I use this tool all the time. Can be used with any DB as long as you have the connector installed on your pc...Leave a comment:
-
In the cmd when you type 'set' you will get all the local variables. use this with system.process and extract the data like so:
...Code:public string GetLV() { System.Diagnostics.Process GetLVP = new System.Diagnostics.Process(); GetLVP.StartInfo.FileName = "cmd.exe"; GetLVP.StartInfo.Arguments = "/c set"; GetLVP.StartInfo.UseShellExecuteLeave a comment:
-
(alpha)R+(beeta )G+(gema)B. You can concatenate the number to have. every color has less than 256 tones in RBG so:
red*1000000+gre en*1000+blue = unique number. Imagine a color defined by:
red = 152
green = 12
blue = 250
then your unique number, if you follow this formula, will be:
152012250
public int RBGtoUnique(int red, int green, int blue)
{
return red*1000000+gre en*1000+blue;...Leave a comment:
-
Thanks guys, That's what I've been using for the past month and it works quite well.Leave a comment:
-
Visual Studio Formatting: how to anchor nested statements
Hi,
This is a simple question.
How do I get statements that are nested (so like an if statement inside an if statement) to have the little +/- button so I can collapse it?
thanks,
Matt -
C# :how to create a delegate to an anonymous(?) button method
Okay so I have a whole bunch of begininvokes to update my gui. I enable/disable, change the text, and all that beautiful stuff.
This is, unfortunately, how my code looks right now:
...Code:public abstract class update { public delegate void button_Callback(object[] pass); public static void button(object[] pass) { Button button = (Button)pass[0]; -
Well I got a little frustrated spending some time trying to get a rectangle from a bitmap and getting an error since my rectangle was out of bounds. I guess it's one of those things you just have to know. I would have thought that visual studio would have a tooltip saying topleft = 0,0 since, as you guys mentioned, there are many conventions.
CheersLeave a comment:
-
c# visual studio express: coordinate standards?
Can someone direct me to the coordinate standards that MS uses to describe it's methods? upper-left corner is 0,0???? since when? in math class it was always bottom left. -
yes but this will freeze my Gui, especially when I call Perl scripts in my testing that take 10 minutes to complete.
I found the answer to my question:
I lock my whole constants class (this is the class with my static methods/variables) whenever I change busy.
so instead of:
I have:Code:constants.busy = false;
...Code:lock(constants){ { constants.busy = false;Leave a comment:
-
c#: help me pinpoint my unsafe thread object!
okay so I have an app that updates it's status every second to run tests and grab information from various files/places on a system. My app works great but I get a funny error from time to time: System.InvalidO perationExcepti on "object is being used" (or something similar).
every second a timer sets off an event. this event creates a thread to run the tests as to not freeze the GUI. However before the test is run, it fetches... -
I let this problem aside for a while and I resolved it using exceptions.
Indeed, each thread would call a perl script that would do work. sometimes the script would stop because of connection issues. I got all my errors from the perl script and pushed them to c# to raise exceptions
voila: no killing, just catching.
As for when the user exits the app in the middle of work, I just let the thread finish on its own.
...Leave a comment:
-
I'm a noob to c# so correct me if I'm wrong:
it isn't quite the same thing: Application.Exi t() is like clicking the X on all currently open forms (even ones open in threads) which leads me to beleive that it frees all resources allocated to the program.
Where is a good resource to see how a certain piece of code frees the memory and deals with threads?
is there some piece of code that will 100% guarantee...Leave a comment:
-
Instead of doing all this I decided to use:
Application.Exi t();
I know it kills threads in waiting status (aka a window in a thread that displays passive data) quite well but will it kill threads in other states?Leave a comment:
-
c# aborting threads on exit idea
I have been reading a lot about aborting threads and there seems to be something missing to do this easily on program exit. This is what I want to do but I will need some help.
I declared a global boolean called KillAllThreads (public static bool in abstact class).
I initialize it to false in my main program before my main window opens.
I then have some threads open and close. I keep count of opened and closed threads...
No activity results to display
Show More
Leave a comment: