|
I have tryed this one But it will not change
|
|
|
|
|
primaryStyle.BorderStyle =BorderStyle.Dotted;
ListBox1.ApplyStyle(primaryStyle);
How about that?
_____________________________
www.DaytonaForums.com
|
|
|
|
|
there is no property like Primarystyle
|
|
|
|
|
Does the framework perform any non-garbage-collector operations that slow down applications at time scales similar to thsoe of garbage collections?
I ask because in my C# code, a certain operation has a measured average case time of a few microseconds, but once in a while one of these operations takes 5000 times longer than the average. This does not appear to be attributable to varying latency in the memory hierarchy or to variations in the code path followed during the operation. Also, I have verified that no garbage collections occur during these long operations by verifying that GC.CollectionCount did not change during the operation.
My timing measurements measure real time, so a factor of 5000 slowdown could easily be due to the operating system, but I thought I would ask here to see if there are any other operations going on in the framework too.
(I am working on a hash table implementation for a real time system; I am interested in the worst-case times for add, remove, and retrieve operations.)
By the way.. Is there a convenient way to time a block of code without using real time measurements such as with WIN32 API calls to QueryPerformanceCounter and the like? It would be especially nice if the data were accessible from within the program so that the program could report the data and compute auxiliary statistics, instead of having to rely on extra steps that are usually required when using a profiler.
|
|
|
|
|
Exceptions can do that. I suggest you attach a profiler, and see what the code does in that bad case.
|
|
|
|
|
The slow operations are rare, at most 1 in 10,000 operations, probably less frequent than that. How would I track this down with a profiler?
Given the nature of the code it does not seem likely that exceptions are being thrown in its midst. There are some calls to the base class library but these use things like List<t> and do not seem likely to involve exceptions.
|
|
|
|
|
A s h wrote: I have verified that no garbage collections occur during these long operations
In this case, it could be linked to Windows memory management. I do not know if you
allocate large blocks of memory, or a lot of small blocks. When you ask for memory,
windows will try not to allocate it. If you actually use the memory, that will cause
a page fault and windows will either create a new page, or swap one from the disk
(depending on the situation).
If you want your system to be under tight constraints, you might have to (try to) manage the
memory yourself.
|
|
|
|
|
The class does small to medium size allocations, generally 32-1000 bytes at a time. The class implementation does a bit of custom memory management in the sense that it maintains a pool of objects for one type of commonly used object.
The class runs completely in managed code and I am not willing to change that - this is a general-purpose library-style implementation of a data structure (with essentially the same interface as ystems.Collection.Generic.Dictionary) that is intended for use within managed or unmanaged programs. The test framework does use the WIN32 API to do timing measurements. That is the only part of the test framework that runs in unmanaged code.
The amount of time used during these slowdowns is on the order of .02 seconds. Sorry for not mentioning this explicitly in the original post. This amount of time seems orders of magnitude too large to be accounted for by page faults. What do you think?
|
|
|
|
|
You should take a look at:
http://blogs.msdn.com/ricom/[^]
Also you could search for "GC mid-life crisis", that would give you pointers to
more details on how the Garbage collector works, and interactions with the OS.
|
|
|
|
|
Thanks.
I think I know what the slowdown is due to - it is probably due to JITting. Now, if I knew how to force the compiler to JIT everything without having to do it in an ad-hoc way like running the benchmark twice..
-- modified at 17:34 Tuesday 5th December, 2006
|
|
|
|
|
hi
i have question about creating subdomain name
if i have domain name is http://www.site.com
i just need to know how to create http://myname.site.com in C#
thanks
|
|
|
|
|
No, you need a DNS record for that.
|
|
|
|
|
Hi, I am wondering if there is a way to create a function in webservices to upload a file without using visual studio2005 designer. I don't want to use microsoft FileUpload controller.
thanks
|
|
|
|
|
A webservice can just be written to take a byte array. Do you mean a web service ? The FileUpload controller lives in a web page, not a web service.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks for your answer, Well, I have seen uploading a file through microsoft fileupload controller.
That was ready made controller provided to us and used all the method and properties to upload a file on the desired destination.
Can we get the same functionality while doing the backhand or core prgramming. I want my webservice to upload a file based on the parameter it receives like: public void myupload(string fileFrom,FileTo);.
How can we do?
thanks
|
|
|
|
|
You can't. A web service needs to be passed a byte[] representing the file, not a file path. A fat client program can provide this, as can a web page, but the web page needs to use the Microsoft conrol, a standard HTML one, or a third party alternative.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
hi all
since i can't describe my problem well, plz check this code,
in this code i can sort the list for the x variable -this is fine and working-
but wat if i want also to be able to sort the list with y variable as well.
i can only use IComparable.Compare with x, i want also to be able to sort the list for y variable
how can i do that????
thanks in advance
how can i do that
using System;
using System.Collections;
using System.Collections.Generic;
public class SamplesArrayList
{
public class Test : IComparable
{
public int x;
public int y;
//this is the variable which i want to sort the list with it also
public Test(int x)
{
this.x = x;
}
int IComparable.CompareTo(object x)
{
Test x1 = (Test)x;
return (this.x.CompareTo(x1.x));
}
}
public static void Main()
{
ArrayList test = new ArrayList();
Test l1 = new Test(7);
Test l2 = new Test(3);
Test l3 = new Test(9);
Test l4 = new Test(2);
Test l5 = new Test(4);
test.Add(l1);
test.Add(l2);
test.Add(l3);
test.Add(l4);
test.Add(l5);
test.Sort();
}
}
|
|
|
|
|
yosif4444 wrote: int IComparable.CompareTo(object x)
{
Test x1 = (Test)x;
return (this.x.CompareTo(x1.x));
}
Your compare to can do whatever you like. You return an int, which specifies how far apart two items are, and in what direction. If you want to sort for y within x, then this would work:
if (x == x1.x)
{
return y - x1.y);
}
else
{
return x - x1.x;
}
Or, pass on to the int compareTo, if you want.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
i think i described my problem wrong
i want to sort the list with either x or y not with both of them
say
object1 x = 5, y = 10
object2 x = 3, y = 7
object3 x = 7, y = 4
Test.Sort() //for x
output
object2
object1
object3
or
Test.Sort() //for y
output
object3
object2
object1
i hope u got wat i mean
thanks
|
|
|
|
|
yosif4444 wrote: i want to sort the list with either x or y not with both of them
So what part of "do whatever you like" don't you understand?
Christian Graus wrote: Your compare to can do whatever you like
led mike
|
|
|
|
|
I know that i can "do whatever i want" but only in one compare function
i want to write many compare functions depending on the variable i want
|
|
|
|
|
OK - I get it.
Create an enum for the different sort orders, then use an instance of that to decide what to do in the compare function.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Yeah you got my point
but can u plz help me with code example, coz i don't know how to implement wat u said
thanks in advance
|
|
|
|
|
OK, it's pretty simple
public class SamplesArrayList
{
public class Test : IComparable
{
public enum SortBy { SortByX, SortByY };
private SortBy _sortOrder;
public SortBy
{
get { return _sortOrder; }
set { _sortOrder = value; }
}
public int x;
public int y;
//this is the variable which i want to sort the list with it also
public Test(int x)
{
this.x = x;
}
int IComparable.CompareTo(object x)
{
Test x1 = (Test)x;
switch(SortOrder)
{
int result;
case SortBy.SortByX:
result = (this.x.CompareTo(x1.x));
break;
case SortBy.SortByY:
result = (this.y.CompareTo(x1.y));
break;
default:
throw new ArgumentException("The SortBy enum has been added to, but the CompareTo method has not been updated");
break;
}
return result;
}
}
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Try it ---
using System;
using System.Collections;
using System.Collections.Generic;
public class SamplesArrayList
{
static char indi;
public class Test : IComparable
{
public int x;
public int y;
//this is the variable which i want to sort the list with it also
public char indi;
public Test(int x, int y)
{
this.x = x;
this.y = y;
}
int IComparable.CompareTo(object x)
{
if (indi == 'X')
{
Test x1 = (Test)x;
return (this.x.CompareTo(x1.x));
}
else
{
Test y1 = (Test)x;
return (this.y.CompareTo(y1.y));
}
}
}
public static void Main()
{
ArrayList test = new ArrayList();
Test l1 = new Test(7,8);
Test l2 = new Test(3,2);
Test l3 = new Test(9,1);
Test l4 = new Test(2,0);
Test l5 = new Test(4,5);
indi = 'X';
test.Add(l1);
test.Add(l2);
test.Add(l3);
test.Add(l4);
test.Add(l5);
test.Sort();
foreach (Test t in test)
{
Test x1 = t;
Console.WriteLine(x1.x+ " "+ x1.y);
}
Console.ReadKey();
}
}
|
|
|
|