|
Hi,
Visual Studio generates a couple of using statements automatically when
creating a new C# file.
The Visual Designer always generates code with fully qualified type names,
so no ambiguity can creep in.
Some people insist on not using using statements at all, and always have fully
qualified type names.
But as a programmer you are free to use or not use using statements, and to use or not use
fully qualified type names, as long as the compiler can find them and find them
without ambiguity.
There is no performance difference whatsoever.
|
|
|
|
|
Thanks for the prompt reply
glad to here there are no perfomance issues.
I have to admit that code is far easier to read without fully qualified type names.
Cheers again,
Janet
Lady Programmers are a rare breed!
|
|
|
|
|
You're welcome.
But_Im_a_Lady wrote: code is far easier to read without fully qualified type names.
That may change when your programs becomes very large though.
|
|
|
|
|
I have a program that tests DB tables. As these tests can take up to several minutes, I want to outsource them into other threads, to at least give the user to possibility to abort them/exit the application.
It's not intended that the user can execute several tests at a time, so I actually only need the main thread in which the Windows Form is running and a single worker thread that performs the test.
My main problem is that I run the test table by table in a loop and each time a table has finished testing, several dictionaries and controls are updated.
When the tests is performed by another thread, it means that the user can access the same dictionaries the testing thread is updating.
So far I just tried to get the testing thread running and allow the user to abort it but I didn't have much success yet.
I used the Windows Forms Invoke Method but that doesn't seem to help much, as the GUI still doesn't respond until the test is finished.
Could you tell me what approach would be best?
Should I use a ParameterizedThreadStart that gets passed a list of all dictionaries?
And how would I go about updating the Windows Forms controls? Create some event that is fired when a table has finished testing?
Thanks in advance.
|
|
|
|
|
Have a look at the BackgroundWorker component.
Dave
|
|
|
|
|
You could try to use the System.ComponentModel.BackgroundWorker class. The DB access takes place in an DoWork event handler.
For more information take a look at MSDN[^]
Hope this will help you.
PS: DaveyM69 was faster :=)
|
|
|
|
|
Thanks!
I've tried it and it seems the BackgroundWorker is indeed a good solution.
It's just a hassle, because during the test the worker thread needs to access a variety of lists and update several controls on the form.
I'm using ArrayLists as arguments to provide data for the worker thread and send the results of it to the form.
It's a bit awkward as I have to cast not only the argument object but also the content, is there any better solution that is more type safe?
|
|
|
|
|
Maybe create a class of data types/objects that may need to be passed back and report that object to the main thread. Just one cast will be needed then.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
There still is a little problem left, I'd appreciate if you could help me out again.
I was wondering whether or not a BackgroundWorker thread releases the locks on objects it held while doing the work, if it is canceled.
If not, is there a way to release the locks without using Monitor.Exit or using that method after I verified that the thread still owns the lock on the object?
|
|
|
|
|
ia m using pivot table in my c# application
my code is
SqlConnection cn=new SqlConnection("database=durdu;user id=sa;pwd=");
SqlDataAdapter cmd=new SqlDataAdapter ("select * from marksheet",cn);
DataSet ds = new DataSet();
DataTable dt=new DataTable();
cmd.Fill(ds);
dt = ds.Tables["Marksheet"];
axPivotTable1.DataSource=(msdatasrc.DataSource)(object)dt;
i have a problem because my pivot table does not show any data
is this a correct way i am bindind data to a pivit table or
what can i do to bind data in pivot table.
please provide me any code example how to bind data in a pivot table
thanks in advance
|
|
|
|
|
Please stop posting the same question. You've asked the same question 3 times in the last 24 hours, and have ignored the replies you already had. I suggest you revisit your earlier[^] questions, rather than opening up new ones.
|
|
|
|
|
How to compare two XML Files and generate the differences in a third file...
say for example...
string sXMLContent1;
string sXMLContent2;
I want to compare these two XML contents. NOTE: i don't want to use string.compare function. i want to check all the sub nodes. and write the difference in a out put file.
Your thoughts are higly appreciated. I want to do it in C#
Thanks,
Prince
|
|
|
|
|
|
Hi all.......
I have to put a checkbox in a DateTimePicker. My idea is whenever I check the checkbox the datetimepicker will be activited and will be disabled otherwise. if anybody knows the solution plz help me out. thanks
Best Wishes
Kaustav Ganguly
Mindteck India
|
|
|
|
|
How about making a user control? Add a DateTimePicker and a CheckBox and in the CheckedChanged event
dateTimePicker1.Enabled = checkBox1.Checked;
Dave
|
|
|
|
|
DateTimePicker.ShowCheckBox = true;
|
|
|
|
|
i have declared an object of a form in other form for accessin a flag value. but it is not able to access it.
|
|
|
|
|
There are several ways to do this.
The best way is to create an event in the second form (FlagChanged) that can be listened to from anywhere - including the first form.
Second best is to create a class (FlaggedForm) that inherits from Form and add the Flag property to your class.
There are other much dirtier methods (that I won't mention!)
Dave
|
|
|
|
|
If you are talking about that flag being not accessible, the closest thing I can suggest is that you have a look at its access modifier, should be public .
|
|
|
|
|
Hi,
i want know if glade, sharpdevelop or monodevelop can do some applications (in mono) that have an interface like media center.
what the pertinent IDE can i use for that goal
thanks
Soufiane
|
|
|
|
|
The easiest IDE to do it in would be visual studio 2008 (There's a free express edition), and using WPF.
mono doesn't support WPF yet though, so might not be any good for you.
I'm assuming then that you're talking about a win-forms app. Any IDE will do for this (think VS2008 is probably still the best), But it's going to be a lot of manual/owner drawn controls, it's not the easiest thing in the world to do. It's certainly not do-able just by pointing and clicking your way through it. Probably best to look for some 3rd party skinable control library.
Simon
|
|
|
|
|
hi,thanks for the answer, but the probl that i must work in UNIX
do u have a solution?
Soufiane
|
|
|
|
|
Well if you have to do the work in UNIX just pick one of those IDEs, they're all gonna give you about the same levels of support I would assume. A media player like interface is going to pretty much have to be all owner drawn, so you're going to spend a lot of your time writing graphics code to draw all the pretty shapes.
There isn't a simple point and click interface for this kind of custom fancy stuff.
That or find a 3rd party control library that works on mono, and has skinable controls.
Simon
|
|
|
|
|
Here is the code:
public Document(string title, string source,string summery, string [] filesList, int noOfFiles)
{
this.title = title;
this.source = source;
this.summery = summery;
this.noOfFiles = noOfFiles;
this.filesList = filesList;
this.pathsList = filesList;
string [] temp;
for(int i=0; i<noOfFiles; i++)
{
temp = pathsList[i].Split('\\');
this.filesList[i] = temp[temp.Length-1];
}
}
the array pathsList holds the full path of the files
the array filesList hold the abstract names of the files
As you see in the code, in the loop I update only the filesList
The MAGIC is, the pathsList is updated too
Can any why tell me how this happens?
Mohammed Gouda
foreach(Minute m in MyLife)
myExperience++;
|
|
|
|
|
Mohammed Gouda wrote: this.filesList = filesList;
this.pathsList = filesList;
Because you are modifying the same instance. Make a copy of pathsList.
|
|
|
|