|
kontrolakka wrote: Do I require the team edition?
You require Team Developer, Team Tester or Team Suite edition.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
kontrolakka wrote: Do I require the team edition?
For the integrated stuff from Microsoft, yep. Team Edition is the only one with Unittesting integrated.
You might want to look into NUnit[^] as a free alternative.
|
|
|
|
|
Absolutely, it works just fine.
And for simple cases, you can also implement a much simplified test harness yourself,
inside your app (so it searches for TestFixtures and executes them one by one).
|
|
|
|
|
I'm using csUnit, which features a nifty VS2005 plugin, but is otherwise the same as nUnit. You can find it here.
Standards are great! Everybody should have one!
|
|
|
|
|
Don't tell me, tell the OP. I'm on Team System myself, so...
|
|
|
|
|
The good news is that Visual Studio 2008 Pro will have unit tests. However, at the present time it seems that the open source unit test tools (possibly augmented by add-ins) are generally better than what is currently supplied with VS 2005.
Kevin
|
|
|
|
|
I want to get a (int) i=i+1 if I click a button every time ;
that is say , if I click onece i==1;
if I click twice ,i==2; and so on.
thank the one help me!
|
|
|
|
|
Hi Lockepeak,
What do you mean with ' click once ' and click ' twice.
Do you mean single click and double click, because in that case you can easily do :
this.button.Click += new System.EventHandler(this.method1);<br />
this.button.DoubleClick + new System.EventHandler(this.method2);
If you mean click once, and then add 1 to i , you could do :
private void method1(object sender, EventArgs e)<br />
{<br />
i=(i+1);<br />
}
assuming that you int i referenced in your application.
|
|
|
|
|
the answer:
If you mean click once, and then add 1 to i , you could do :
private void method1(object sender, EventArgs e)
{
i=(i+1);
}
assuming that you int i referenced in your application.
the method can't get the right anwser. whatever I click several times the value allways begin value
|
|
|
|
|
well, I'm not sure what you're doing wrong but I just made a test project and it works perfect. Every single time I click the button , 1 is added to int i . What I think the problem is , is that you don't have the integer referenced properly in your application. You have to reference it throughout the entire form so that it remembers the previous value:
namespace Blah<br />
{<br />
public partial class Form1 : Form<br />
{<br />
int i = 0;<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
private void button3_Click(object sender, EventArgs e)<br />
{<br />
i = (i + 1);<br />
MessageBox.Show(i.ToString());<br />
lbl.Text = i.ToString();
}<br />
<br />
}<br />
}<br />
}
if you reference int i anywhere else in the project, it will reset the value as soon as you dispose the messagebox. Intead of the messagebox, you could use a label to see the number increase everytime you click the button.
Hope this helped.
|
|
|
|
|
When the button onclick event fires have this in your code i++;
|
|
|
|
|
Why does the simple exercise below throw a StackOverflowException? I didn't think I was looping or doing anything recursive.
namespace ArrayTests
{
class HasArray
{
public int[] ExampleArray
{
set
{
ExampleArray = value;
}
}
public HasArray()
{
int [] ExampleArray = new int[2] { 1, 2 };
}
}
class Program
{
static void Main(string[] args)
{
HasArray concreteHasArray = new HasArray();
int[] otherArray = new int[2] { 3, 4 };
concreteHasArray.ExampleArray = otherArray;
}
}
}
|
|
|
|
|
But, you were doing something recursive. In ExampleArray property, through set method, you were setting value to the same property. To see this by yourself, set breakpoint on beginning of Main() method and press F11 key several times. You can correct your HasArray class by adding one attribute of integer array type to it which holds the value for ExampleArray property.
This is what I mean:
class HasArray
{
private int[] _exampleArray;
public int[] ExampleArray
{
get { return _exampleArray; }
set { _exampleArray = value; }
}
public HasArray()
{
_exampleArray = new int[2] { 1, 2 };
}
}
|
|
|
|
|
Hi Cristian,
The problem is here:
public int[] ExampleArray
{
set
{
ExampleArray = value;
}
}
In the Setter curly Brackets you reset the property (Same Name), so when you call concreteHasArray.ExampleArray = otherArray;
you conccurently setting the ExampleAray.
Solution:
<br />
namespace ArrayTests<br />
{<br />
class HasArray<br />
{<br />
private int[] _ExampleArray ;
public int[] ExampleArray<br />
{<br />
set<br />
{<br />
_ExampleArray = value;
}<br />
get{return _ExampleArray;}
}<br />
public HasArray()<br />
{<br />
ExampleArray = new int[2] { 1, 2 };<br />
}<br />
}<br />
<br />
class Program<br />
{<br />
static void Main(string[] args)<br />
{<br />
HasArray concreteHasArray = new HasArray();<br />
int[] otherArray = new int[2] { 3, 4 };<br />
concreteHasArray.ExampleArray = otherArray;<br />
}<br />
}<br />
}<br />
Hope this helps
Nassos
GanDad
|
|
|
|
|
public int[] ExampleArray
{
set
{
ExampleArray = value;
}
}
Basically, what you're saying here is:
"In order to assign a value to ExampleArray, you first assign the value to ExampleArray by assigning a value to ExampleArray by assigning a ......"
The "standard" property format is as follows:
private int _myVar;
public int MyProperty
{
get
{
return _myVar;
}
set
{
_myVar = value;
}
}
You see, the variable is what holds the actual data... The property is just a way to access it.
|
|
|
|
|
What method do you think is better when there are many threads?
Regards,
Analizzatore Cloro
|
|
|
|
|
Ooooooh....
I thought I was just saving myself the time to set up private and public parts. Now I see it is recursive, of course! Thanks!
|
|
|
|
|
I'd like to know if there is any mechanism to know where the threads that ThreadPool object manages, are finished.
The idea is having a loop that calls the ThreadPool to execute some method, and then block that main thread until all threads are finished.
Is that possible?
Regards,
Diego F.
|
|
|
|
|
Diego F. wrote: The idea is having a loop that calls the ThreadPool to execute some method, and then block that main thread until all threads are finished.
Then why would you even use threading at all??
The whole point behind threading is to move work to a seperate thread so your primary thread can continue to respond to requests.
The thread pool doesn't raise any events when a thread is complete. Your threaded code has to supply that, or some other method to signal completion.
|
|
|
|
|
Well, in my case, I don't mind to block the main thread. The help of ThreadPool is that I need to run a method many times (let's say hundreds), and if I can run it separately, I would think that it saves time.
Am I wrong? Other way, you are rigth. It has no sense the use of threading.
Regards,
Diego F.
|
|
|
|
|
Hi,
AFAIK there is no built-in mechanism for this.
I see at least three possibilities:
1.
You could try to count yourself; use Interlocked.Increment each time you send
a piece of work to a thread, and have it call Interlocked.Decrement when it is done.
Then have your main thread do a busy wait (with Sleep!) on the same counter.
disadvantages:
- if a thread exits abnormally (or forgets to decrement) your main
thread will hang forever.
- the wait loop is not nice.
2.
Since .NET 2.0 there is BackgroundWorker class, which supports cancellation and
offers events. You could use its IsBusy property and/or its ProgressChanged event.
3.
And of course you could use regular threads, keep them in a list, and periodically
check their status. (Dont forget to clear the list when you conclude all has been
done; so the threads get garbage collected).
|
|
|
|
|
Thank you for your ideas.
What method do you think is better when there are many threads?
Regards,
Diego F.
|
|
|
|
|
I am not sure:
- I have not used BackgroundWorker yet;
- I have limited experience with ThreadPool; IMHO it lacks some functionality.
- most often I use regular threads, so I can easily manage them (e.g. change their
priority).
Diego F. wrote: when there are many threads?
what is many ?
It is my view that executing the same work in more than a couple of threads does
not improve performance: all these threads start to compete with one another
(they all want CPU cycles, or all want disk access, or...). So having 2 or 3 or 4
seems a maximum.
The one good reason I can come up with for really many similar threads is for
encapsulating independent jobs (as would be the case in a server with many clients).
BTW: when using real Threads, you can also do the following:
- for each new thread you create, add it to a list
remark: you probably want to set IsBackground true
- create a loop over that list, performing a Thread.Join();
when that loop finishes, all threads are done (does not matter in what order!).
advantage: no need to count
remark: clear the list when done
- you might even create an extra thread to run that loop, so it does the waitforall
logic, while your main thread can go on doing whatever it likes to do...
Hope this helps.
|
|
|
|
|
Would this post[^] also be by your hand or is this person just copying and pasting your words?
|
|
|
|
|
Hi, I am trying to write a program in C# that will ask for a password before running any program. Suppose if any one wants to run MS Word he has to enter the password. Now my question is how can I set the password check before executing a program?
Please let me know if any of know how.
Johnny
|
|
|
|