|
Here's one simple question. How do you quantify on cost of context switches? And how can you decide whether or not a method should be executed synchronously or asychronously?
I hestitate on logging the time at which the thread is launched and the time the first line the thread func is run... Perhaps I should take average of these time logs to decide if the function really should be executed synch or async...
Anyway, for ASP.NET application... Here's a reference
Norman Fung
|
|
|
|
|
It's not always a question of time - but when it is, only you can answer that question because only you know your requirements and only you know what's acceptable. It's like a doctor asking a patient about their pain on a scale from 1 to 10. There's no standard. Only you can answer it.
When it's not about time, it's about execution. If need to download a file but want the user to be able to continue using your application, then you should download the file asynchronously. If you need to display a dialog while this is happening, that should be displayed in the UI threa while the download occurs in a background thread. It's those types of requirements that also drive whether or not you should use synchronous or asynchronous calls.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks. My concern is that I've synchronous access to locked resources (cached user credentials, access tokens, and a bunch of other security related information). And that automatically implies some limitation on scalability. But, how can one tell if launching more threads (in which case penalty is context switches) is more/less efficient than executing synchronous (in which case penalty is concurrent access to locked resources).
Norman Fung
|
|
|
|
|
|
How can I determine if an audio CD or DVD is inserted? I already used the sample of detecting a disk being inserted/removed fron CP, but I need to determine i it's a movie or audio disk.
I have been searching on Google and Yahoo all morning with no real sucess. Any help would be appreciated.
Regards
Eric C. Tomlinson
No comment, Mr. Senator<pre>
|
|
|
|
|
Detect what files are on the disk. If it's an Audio CD, Windows displays the CD data as .wav files (IIRC, it's been a long time since I actually looked - just try it). A movie CD (by which I assume you mean either a VCD or DVD) also contains certain file types.
This is actually what Windows Explorer for XP does when you insert CDs. Sometimes it's quick because certain types of files can be detected quickly. Other types, you actually see it searching the disk's content. That's how it determines what items to display in the new Auto Run dialog for Windows XP.
Note that Windows Explorer interprets data on an Audio CD differently than other platforms might. The CD is not really comprised of WAV files, but WAV data. It's up to the Window manager or other application to interpret that data and display it as files if so desired. It actually has more to do with file systems than anything.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
So basically read the drive to determine/set the type of disk. I suspected this but was hoping you could query the system about it after insertion of the disk. I'm going to override the autoplay for certain types of files. Thanks again Heath for the short sweet answer and the good point in the correct direction.
Regards
Eric C. Tomlinson
No comment, Mr. Senator<pre>
|
|
|
|
|
In new projects i have been used C#, but my boss ask me Why C# ?
If the FrameWork is the same, why i used the C# ?
" I used because this language is better than VB.NET in OOP."
Is this correct? I don´t remember where i read this information.
Are there any Documents , Articles .... about : VB.NET x C# ?
Wich language is the best ?
thanks for help
|
|
|
|
|
You deleted your post from Lounge withing few minutes and posted it here. Smart move.
You can find your answer in C# Frequently Asked Questions blog[^] by c# team.
//Start of joke
Never comment ur code. If it was hard to write, it should be hard to understand !!!
//End of joke
|
|
|
|
|
Sorry, the Lounge is not for coding questions.
Thanks for help
|
|
|
|
|
Search the comments. Recently there was a discussion about that issue.
|
|
|
|
|
Like Stefan said, there was a similar discussion about 2 weeks back[^]
Luis Ricardo wrote:
In new projects i have been used C#, but my boss ask me Why C# ?
What would indicate to your boss that you should pick something else. If you know C# better than VB.NET then why not?
Luis Ricardo wrote:
" I used because this language is better than VB.NET in OOP."
Well, they have similar features, just a different syntax. C# does take more advantage of features of the CLR so it is probably just ahead.
Luis Ricardo wrote:
Wich language is the best ?
That question is very loaded, there are two camps and people on each will defend their position as to why their choice is better. However, IMO, it is all really what you know best.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
|
|
|
|
|
Thanks. I will read the similar discussion.
|
|
|
|
|
|
Syntactically, Visual Basic .NET and Visual C# .NET are two different languages, just as Visual Basic, Visual C, and Visual C++ are different languages. Visual C# .NET looks more familiar to Visual C, Visual C++, and Java programmers, and Visual Basic .NET looks more familiar to Visual Basic developers. The biggest differences between the languages fall into the following categories:
Case sensitivity
dentifier names in Visual Basic .NET are not case-sensitive, but identifier names in Visual C# .NET are case sensitive.
Variable declaration and assignment
Variables in Visual Basic .NET are declared with the variable before the data type. In Visual C# .NET, the data type precedes the variables.
Data types
Integer in Visual Basic .NET is int in Visual C# .NET. However, System.Int32, the .NET Framework base type for which Integer and int are aliases, can be used in both languages. Visual C# .NET also supports the signed byte, unsigned short, unsigned int, and unsigned long data types, which are not available in Visual Basic .NET.
Statement termination
Statements in Visual Basic .NET are terminated by the end of the line. You can use the colon ( to put multiple statements in a line, and you can use the line continuation (_) character to make a statement span several lines.
Statements in Visual C# .NET are terminated by the semicolon (;). You can use multiple statements per line, and statements can span multiple lines.
Statement blocks
Visual Basic .NET does not use arbitrary statement blocks. Instead, certain keywords that have a specialized terminating statement are used instead of the statement blocks.
In Visual C# .NET, braces ({}) are used to delimit a statement block; otherwise, a single statement is assumed.
Use of () vs. []
Visual Basic .NET uses parentheses () to delimit array elements, function arguments, and property indexes.
Visual C# .NET uses parentheses () to delimit function arguments, and brackets ([]) to delimit array elements and property indexes.
Error handling
Visual Basic .NET supports both structured and unstructured error handling, but Visual C# .NET supports only structured error handling.
Overflow checking
Visual Basic .NET has a project level setting to check for overflow. However, the checking can only be turned on and off at the project level, instead of at the level of an expression or a block of code. Visual C# .NET statements can run in either a checked or an unchecked context. In a checked context, arithmetic overflow raises an exception error. In an unchecked context, arithmetic overflow is ignored and the result is truncated. This can be used on an expression or a block of code.
Late binding
Both Visual Basic .NET and Visual C# .NET can implement implicit late binding through reflection. However, implementing late binding in Visual Basic .NET is much easier than in Visual C# .NET.
Handling unmanaged code
Visual C# .NET permits you to write unmanaged code. In unmanaged code, you can do things such as declare and operate on pointers, perform conversions between pointers and integral types, and take the address of variables. In a sense, writing unmanaged code is much like writing Visual C code in a Visual C# .NET program.
n Visual Basic .NET, you cannot write unmanaged code.
Sreejith S S Nair
|
|
|
|
|
I need to change the secuirty settings of an IIS Virtual dir programatically. I have to disable annonymous login and leave only integrated secuirty enabled. Does anyone know how can I do this ?
I tried the DirectoryServices ("IIS://") stuff but is giving me an COM error.
Mauricio Ritter - Brazil
Sonorking now: 100.13560 MRitter
English is not my native language so, if you find any spelling erros in my posts, please let me know.
|
|
|
|
|
How many times to do I have to say this: if you're getting an error, tell us what it is? How do you expect us to help you?
Using directory services is the preferred way, and in most cases the only way.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I have a datagrid . I filled the grid with values and now I want to keep check boxes beside every column header in the datagrid. I want check boxes only in each column header cell. How do I do this?
Karteek.
|
|
|
|
|
You laready asked this about 24 hours ago. Be patient, or learn to research solutions yourself. It's very rude.
In any case, like I said in my previous post[^], the DataGrid in the .NET 1.x FCL does not support this, nor does it make it easy to implement. Either use a third-party control (of which I listed a couple in my previous post) or wait till .NET 2.0 where the GridView will be introduced with a lot more customization possible.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've created a very, very simple custom CodeAccessPermission class. It basically does nothing more than override the necessary base class methods and implement IUnrestrictedPermission.
In another class, I want to perform an imperative security check to ensure the caller has been granted my custom permission:
<br />
public static void ReadData()<br />
{<br />
CustomPermission MyPermission = <br />
new CustomPermission(PermissionState.Unrestricted);<br />
MyPermission.Demand();<br />
<br />
}<br />
The problem is, I haven't done anything to specifically grant my application this permission, and when I call Demand no SecurityException is thrown. But, I want a SecurityException to be thrown since I have not explicitly granted any code that permission.
Why does this happen?
- Mike
-------------------------
"No human being would stack books like that." - Dr. Venkman
|
|
|
|
|
You've hopefully already read this, but be sure you're familiar with the content described in Creating Your Own Code Access Permissions[^] in the .NET Framework SDK. Also be sure that your permission class is installed into the GAC and granted FullTrust permissions, as is documented (and for reasons that should be obvious).
If your application is granted FullTrust permissions, than it really doesn't matter what permissions you demand - they will all succeed.
Also, make sure that any callers higher in the stack haven't asserted that permissions (if they have it, they can grant it for children).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I overlooked the subtle fact that all code on the local computer gets Full Trust by default. That's all.
- Mike
-------------------------
"No human being would stack books like that." - Dr. Venkman
|
|
|
|
|
i can get the video stream but i can't transfrer the another computer in the Lan,or internet.
|
|
|
|
|
You have to setup a video server on your host machine. You can get the Windows Media Encoder to be the server or you can start here[^] if you wanted to reinvent the wheel and write one yourself.
RageInTheMachine9532
|
|
|
|
|
I am looking into this myself. I want to have a streaming server with multiple clients running on the same box as the server. Have you found any help or examples on this?
Regards,
Eric C. Tomlinson
I won't dignify your question with an answer. Yes, I program in VB6, but only because I'm addicted to eating!
|
|
|
|