|
The following code should work:
Process.GetCurrentProcess().Threads.Count
www.troschuetz.de
|
|
|
|
|
dear All,
a) downloaded and installed the latest directX sdk for c#
yesterday.
however, discoffered that the documentation is only for c++
although c# is mentioned on the download website.
is there a c# directX doc?
b) i want to make an application showing loads of bars (bit like a bar chart). what is the best fucntion to do this in directX c#.
i was looking at vertex stuff, but i think it's a bit of an overkill for say 256 bars - output of an FFT)
many thanks, Dominik
|
|
|
|
|
As for the answer to b, I suggest the C# multimedia - DirectX[^] section on CP. My article is on a 2D game port and there are others that talk about just 2D and not 3D.
Steve Maier, MCSD MCAD
|
|
|
|
|
Hi all
I wrote an http download manager application for my personal use. First, I tried to open a tcp connection on port 80 and handled the handshake procedure with my own code. However not all servers gives the same replies so my application failed while connecting some secure sites...
Hence I decided to use the benefit of c# and replaced my http handshake stuff with webrequest and webresponse classes. But there is a problem.
Although it successfully downloads at first time, when I try to download another file on the same session, it ALWAYS throws a "(400) bad request" exception.
I even tried to download the same file twice, but again it downloaded on first try but threw the same exception on second try.
I have also tried request.abort() and response.close() methods to close any open connection but nothing changed!
If anyone can help me I'll appreciate.
Sincerely
can
mca@aecteknoloji.com
|
|
|
|
|
The best way of learning what you're doing wrong, is by monitoring HTTP, with a tool like Fiddler[^].
Do the same thing with a browser and your program and pay attention to headers and connections: probably you'll see what you're doing different from the browser and you'll be able to do the same thing with WebRequest and WebResponse.
Yes, even I am blogging now!
|
|
|
|
|
Hi
Thanks for your reply.. I'll try this
|
|
|
|
|
Hi,
imagine a Folder object, that contains a list of File objects. Each File object has a Folder parent. So we have a cyclic dependency here. When I try to return such structure with a web service, I get the following error:
System.Web.Services.Protocols.SoapException: Server was unable to process request. --> There was an error generating the XML document. --> A circular reference was detected while serializing an object of type Folder.
I've read that XmlSerializer can't handle cyclic dependencies. Does this mean that I cannot use web services to return such a structure, or is it a bug and will it be possible in 2.0 for example? Is there some kind of workaround for now?
Thanks in advance!
|
|
|
|
|
I've never tried this on a WebService, but some time ago I needed to serialize a circular reference with the XmlSerializer and it didn't work, but the SoapFormatter could. Since web services use soap, it should work, but I'm only guessing here...
Yes, even I am blogging now!
|
|
|
|
|
Hello,
how I am able to filter directories and copy real files only ?
C:\Temp\Subfolder\
C:\Temp\readme.txt
(Copy only readme.txt, not the Subfolder)
I am using
foreach(string Element in Files)
for getting all elements in a directory.
|
|
|
|
|
|
Use the Directory.GetFiles method to obtain the names of files in a specific directory and afterwards copy the files by using an overload of the File.Copy method.
www.troschuetz.de
|
|
|
|
|
i want write a codeEditor, so i want to know, can you help me?
i know it will uses the RegularExpressions , but i only konw this, i do not know what should i do next.
|
|
|
|
|
I am not sure that you mean, but if I understand you correctly, you need to color some text lines or words in a you application. Allmost all form components have two properties, called FORECOLOR and BACKCOLOR. They can easly be changed a follows:
MyTextBox.ForeColor = Color.Blue;
MyTextBox.BackColor = Color.White;
You can find Color in the namespace "System.Drawing".
Remember to add the line "using System.Drawing;" to top of your file.
|
|
|
|
|
Try SharpDevelop[^].
It's available as free, open source, have a separate syntax coloring editor control, and it's damn well documented - they even wrote a book, available in paper and as a free e-book download.
The control is stable, fast (as fast as this can be done in C#), and flexible.
Yes, even I am blogging now!
|
|
|
|
|
|
hi
i am a computr science studnt i have encountered the following problems in running your codes that i downloaded from your site
1- when i try to run these projects a message occurs that this project should be converted to the current visual studio version format and when i click ok to convert it another message occurs that it cannot be converted because it is a read only file and you must change the permissions on the file what should i do?
2- how do i add refernces in a c sharp project?
|
|
|
|
|
1 - Obviously you downloaded a solution that was created with Visual Studio.NET 2002 and tried to open it with the 2003 version, so the solution has to be converted. This fails because of the write protection of the files, so simply change this with the Windows Explorer. As a computer science student you should know how to do that.
2 - Go to the solution explorer, right-click on the Reference branch of your project, select add reference and then specify the assembly you want to reference to in the opening dialog.
www.troschuetz.de
|
|
|
|
|
how do i print a picture box in c#? include code sample. i am an ex c pgmr teaching myself c# i run visual studio.net on w2000 pro, not xp.
ez
|
|
|
|
|
If u still need some code, shout, i have it somewhere on my drive, printing of images in C#, as well as multipaged Tiff images
WARNING: Running on cold coffee.
|
|
|
|
|
Any body please tell whats the difference between keyword and reserved word
and also tell that if,else,while are keywords or reserved words
Please reply thanx
ihtesham
|
|
|
|
|
All keywords are reserved words in C# . This means u cannot use them as identifiers in your code .
if, else, while are keywords
|
|
|
|
|
Hi,
Since the reader may not be able to read all the data in 1 time. there's a need to read the data from the WebResponse for several times.
I've read some samples that uses a fixed buffer size, say 4096 bytes. Keep reading until all the data are read.
What is the advantage of using a fixed buffer size?
Why not just reading like the following code segment?
WebResponse response = request.GetResponse();
Stream responseStream = response.GetResponseStream();
BinaryReader reader = new BinaryReader (responseStream);
int bytesRead = 0;
byte[] result = new byte[response.ContentLength];
while(bytesRead < result.Length)
{
int bytesToRead = result.Length - bytesRead;
bytesRead += reader.Read(result, bytesRead, bytesToRead);
}
thanks
|
|
|
|
|
khchan wrote:
What is the advantage of using a fixed buffer size?
Why not just reading like the following code segment?
Because not always you'll have the Content-Length header, so you won't know how much to read. Did you ever try a download that IE couldn't show the '% complete'? That's why: in the .NET world, response.ContentLenght can return -1.
One advantage of the read 4k at a time approach is if are scanning through a page looking for some information (e.g., with a XmlReader constructed on top of the ResponseStream), and you may not need to read everything in an array.
And, at last, if you're building something with the ResponseStream (e.g., a string) and won't keep the byte[]. If you allocate arrays bigger than 85k, the GC will send them to a special area were they're not moved when collected, and if you have lots of huge (85k) temporary objects this can lead to bad GC performance.
Besides that, it's just habit and people code things without really asking "hey, why should I do this way?".
Yes, even I am blogging now!
|
|
|
|
|
I am trying to get an understanding about making classes thread-safe.
Since the constructor is called just once for each instance of a class, does it follow that no other consideration needs to be given to ensure the constructor is thread-safe?
Thanks for any help
|
|
|
|
|
Shayne Husson wrote:
I am trying to get an understanding about making classes thread-safe.
Since the constructor is called just once for each instance of a class, does it follow that no other consideration needs to be given to ensure the constructor is thread-safe?
No. However the new Operator[^] is not the problem as it (as you already mentioned) just creates an object, invokes the constructor and returns a reference to the newly created object. This will be thread-safe as long as the constructor does not access any outside object (public MyClass() {} for example is no problem at all). But let's assume you have something like this:
public MyClass(object someObject)
{
}
If you use this constructor in a multithreaded scenario you might end up having concurrent access of someObject . Now if you don't have a synchronization mechanism one thread might end up accessing someObject in an inconsistent state. So ultimately the need for synchronization in the constructor really depends on if and what you're trying to do with any objects which are known outside the constructor.
Best regards
Dennis
|
|
|
|