Finding what you need in the Microsoft� Visual Studio� 2008 documentation, which has over 200,000 topics, can be a daunting task. The Doc Detective is here to help, utilizing his investigative skills to probe the depths of the documentation.
Can't find what you're looking for? Just ask-if it's in there, I'll find it for you; if it isn't, I'll let you know that as well (and tell you where else you might go to find it).
Have a question for the Doc? Send your questions for future columns to me at docdetec@microsoft.com.
Dear Doc Detective,
I really like the performance benefits of asynchronous
method calls that allow my application to do other work while waiting for
file I/O or some other heavy workload to complete. But I sometimes find the IAsyncCallback
pattern cumbersome, and easy to get wrong. There must be an easier way to just “fire and forget” an asynchronous
method call.
Asynchronously waiting for your response.
- Async in Astoria
Dear Async,
Help is on the way! With .NET 4.0, the new System.Threading.Tasks.Task
type simplifies the task of writing asynchronous code. Now, to fire off an asynchronous
method call, you can simply write:
Dim instance As TaskFactory
Dim action As Action
Dim returnValue As Task
returnValue = instance.StartNew(action)
This code creates a new Task
object, queues it onto the ThreadPool
, and starts it running. If necessary, you can wait on the task to finish, or cancel it, or return a value from it, or specify a second task to execute when this task has completed. All this and more is documented in the .NET 4.0 Beta 1 MSDN documentation. Look for the topic, “Task Parallel Library Overview” to get started-asynchronously, of course.
- Doc D
Dear Doc Detective,
I'm just getting started with Silverlight programming and I need your help. I've seen some cool 3-D effects in several Silverlight demos and I'm wondering how these are done. I've looked in the docs but I can't seem to find anything.
- Two Dimensional in Tonawanda
Dear Two,
3-D effects, also known as perspective transforms, are a new feature in Silverlight 3.0. You can use perspective transforms to give the illusion that an object is rotated toward or away from you, to arrange
objects in relation to one another to create a 3-D effect or even to animate the perspective transform properties to create moving 3-D effects.
You can learn more about perspective transforms in the aptly named topic, “3-D Effects (Perspective Transforms)” in the Silverlight 3 Beta 1 docs on MSDN. With a little effort, you can even create your own flaming spinning logo-how cool is that?
- Doc Detective
Dear Doc Detective,
I am writing a program that logs keystrokes. I've already figured out how to get the name of the key being pressed in the KeyDown
event using e.KeyCode.ToString
.
My problem is that when NumLock is on, key presses return the KeyCode
for the number rather than for the functions such as the arrow keys. How can I get the function values instead of the numbers?
- Keyed up in Keystone
Dear Keyed,
Interestingly enough the values returned by KeyCode are somewhat inconsistent. If NumLock is on, pressing the 1 key on the keyboard returns the string “D1” and pressing 1 on the numeric keypad returns “NumPad1”. If Numlock is off, pressing the End key on the keyboard or the 1 key on the numeric keyboard both return “END”.
What this means is that you can't differentiate between the keyboard and the numeric keypad unless NumLock is on. In your case, however, it sounds like you only want to capture the keys when NumLock is off and you don't care whether the key press is coming from the keyboard or keypad. If that is the case, you could simply check the state of the NumLock key and warn the user if it is on.
You can use the Keyboard
object in the My
namespace to check the key state in the KeyDown
event as follows:
If My.Computer.Keyboard.Numlock = True Then
MsgBox("The Numlock key is on!")
Else
MsgBox("You pressed " & e.KeyCode.ToString)
End If
In addition to getting the state of the NumLock key, the Keyboard
object can also return the state of the Alt, CapsLock, Ctrl, ScrollLock, and Shift keys. You can learn more about the Keyboard
object in the topic, “My.Computer.Keyboard Object Members”. As the Doc always says, knowledge is Key.
- Doc D
Dear Doc Detective,
I just downloaded the Visual Studio 2010 Beta after hearing that it now supports the Dynamic Language Runtime and more specifically, using expression trees with the DLR. I was disappointed to see that there isn't much in the way of documentation on MSDN, or maybe I just can't find it-can you help?
- Helpless in Helena
Dear Helpless,
The reason that you can't find much on MSDN is because it isn't there. The documentation for the Dynamic Language Runtime is actually hosted on CodePlex, because there is an open-source release of the DLR in addition to the DLR that ships with Visual Studio.
You can find the documentation by going to CodePlex and searching for Dynamic Language Runtime, or you can go to the MSDN topic “Dynamic Language Runtime Overview” and follow the CodePlex link from there. One note of caution-open-source and .NET releases of DLR may differ, so read carefully.
- Doctor D
Doc's Doc Tip of the Day
Some people learn best by reading; others learn best by watching. If you fall into the latter category, you will want to check out the Video How To's in the Visual Studio 2008 documentation.
Video How To's show you how to complete a particular programming task. The videos correspond to documentation in the MSDN Library, and link to the articles they are based on. You can watch a video to learn how to perform a task, and then go to the written steps for the details and code examples.
Microsoft documentation team add additional videos monthly, so bookmark the Video How To page and return often to see what's new.
Found a topic in Help that doesn't help? Tell the Visual Studio documentation team about it by clicking on the “Send feedback” link in local Help topics, or the “Click to rate and give feedback” link in online Help.
URLs
http://msdn.microsoft.com/en-us/library/dd460717(VS.100).aspx
http://msdn.microsoft.com/en-us/library/dd470131(VS.96).aspx
http://msdn.microsoft.com/en-us/library/ms172976.aspx
http://dlr.codeplex.com/Wiki/View.aspx?title=Docs%20and%20specs