Everything posted by AWS
-
Drukarka Drukuj drukowanie
Czy ktoś mi pomoże?Mam laptopa z systemem Windows 7 Home premium i drukarkę Lexmark Z25.Nie mogę poprawnie jej zainstalować.Jest tak,że wyświetla się komunikat(po próbie instalacji):POMYŚLNIE ZAINSTALOWANO DRUKARKĘ,lub TO URZĄDZENIE DZIAŁA POPRAWNIE,aby po próbie wydrukowania strony testowej dowiedzieć się,że drukarka nie jest ustawiona jako domyślna-MIMO,ŻE WŁAŚNIE TAK JEST USTAWIONA i ustawienie to 2-3 krotnie sprawdzałem,zarówno przed, jak i po próbie drukowania.Często też po kolejnej,na nowo próbie instalacji pojawia się komunikat BŁĄD DRUKARKI.Co zrobić,jak ją zainstalować.Skłonny jestem udostępnić laptopa do"pomocy zdalnej"dla zainstalowania drukarki.Wspomnę też,że firma producenta(Lexmark)nie ma sterowników ani oprogramowania w/w modelu.Traktują ją jako przeżytek.Proszę o pomoc. View the thread
-
My Pc stopped accessing all my RAM
Hello all PC: OS: Windows 7 Enterprise SP1, 64-bit, processor: Core i7-2720QM, RAM: 8Gb Problem: for the last two days, every time i check computer properties it says: 8.00 Gb (7.90 Gb usable). I re-assessed my computer performance but nothing changed. Question: why cannot my PC use all the 8Gb of ram??? any ideas or help please. Win7-Geek View the thread
-
how do I change my viewing from centimeters to inches?
when I am working with pictures and/or tables, I want to see the sizes in inches, and not in centimeters .... there must be a way to change this?!! View the thread
-
office professional plus
i purchased a lenovo c200 AIO pc.it had office professional plus 2010 preinstalled.when i opened ms word i get a message saying 3 days left for activation.i do not have any product key.what should i do? View this thread
-
I get a message "NVIDIA graphics driver has stopped working",
My PC monitor blew and I got another, but it's an LED TV that I am using as PC monitor. Do I need the NVIDIA graphics driver? View this thread
-
hi, Ive installed windows 8 preview now I don't have a Games folder. I miss the Spider Solitaire, ca
Since installing Windows8 Preview I have not been able to find Spider Solitaire, The Games folder is not there either, any suggestions? View this thread
-
Lost Taskbar icons
I have somehow lost my voume and power icons in my taskbar how do I get them back? I am unable to click on them in the Taskbar and Start Menu Notifications Area box. View this thread
-
Building the Mail app
When we started planning the email experience for Windows 8, our goal was to create an app that embodied the Metro style design principles. It needed to be fast and fluid, be great with touch and a keyboard and mouse, focus on your content, provide the right features at the right time, and fulfill our expectations of email on modern devices. Starting from scratch gave us an opportunity to carry forward the essential functions of an email app, while also designing features with a fresh eye and taking advantage of what Windows 8 offers uniquely. How people use email today At the start of our design process, we conducted research into how people use email today. Email has been around for decades. It’s changed a lot and so have our expectations. Multiple email accounts are common. The average user has 2 to 3 email accounts. One is for work, one is personal, and another account might be used primarily for mailing lists and coupons, or isn’t used frequently, like an account from a school that you no longer attend. We receive a lot of email. Our data shows that those who we would consider light email users receive more than about 180 messages a week, while heavy email users receive more than 2100 messages a week. These numbers are growing as more services come online and support newsletters, coupons, receipts, and other types of messages via email. We need to make it easy to quickly get through all your email. Folders aren’t used that often. This is probably a surprise to many people who rely heavily on folders, which is a very common practice in many enterprise environments, and for enthusiasts. At some enterprises, users have up to 50 folders, while the majority of people using Exchange and Hotmail have far fewer folders. The right balance for Mail was to make folders easy to use, but not to optimize for 50+ folders and deeply-nested hierarchies. Email is real-time. While email is often used for asynchronous communication, where you don’t expect an immediate response, more and more, the expectation is for an immediate, real-time response. After you sign up for a new service, you’re often told to expect an email immediately. We expect to be notified the instant a new email comes in and most people check their email frequently throughout the day or leave it running all day long so they can see every message as it comes in. People expect consistency with mobile phone experiences. Many people are using their phones in conjunction with their PCs. In fact, they’re using their phones for triage, reading, and filing away of mail (among other things). The importance of consistency between your phone view and PC view of email are more important than ever. The use of standard protocols such as Exchange Active Sync as implemented in the Mail app are increasingly important, especially because this protocol allows for syncing of contacts and calendar, in addition to mail. (Don’t worry, support for other protocols, such as IMAP, are on the way.) We took these trends into account as guiding principles as we began to consider how people would use the Mail app to manage their email, write messages, and stay up-to-date. Managing email Accounts and folders One of the goals of Metro style design is to emphasize the content of the app, and de-emphasize UI commands or navigation that you use rarely. We wanted the Mail app to allow you to focus on the most important aspects of doing email. The 16:9 aspect ratio of Windows 8 made it possible for us to comfortably fit all the essential pieces of content that we use every day: accounts, folders, messages, and a reading pane. It provides an easy way for you to quickly take in all of your email without switching views, and while still feeling open. This is a change from the way it appeared in Consumer Preview, where we only showed messages and a reading pane. We realized that switching accounts and folders wasn’t fast and fluid enough (and customer feedback supported this conclusion). Because folders and accounts are key pieces of content that you need to see, we updated the design to show them in Release Preview. . 3-pane design of the Mail app Both of these realizations led to the 3-pane design that you see in the Release Preview today. This design shows your different accounts so it is just just one tap to switch between them. The unread count on each account makes it easy to see if you have new mail to look at in that account. The same is true for folders. Even though most users don’t have many folders, they are a core way that many people use email, so we made it easy to quickly switch between them. An always-present folder list is especially valuable for people who use server rules to automatically filter their email into specific folders. Commands We spent a lot of time deciding which functionality, or commands,would be always visible in the app so that most people wouldn’t be distracted by commands they never used. We decided to include commands for the tasks that every person uses almost every time they launch Mail: creating, responding to, and deleting messages. All the respond commands are grouped into a single top-level command since they preform a similar function. Delete is in the corner, which also aligns with the Cancel command when writing an email. Some people change the read/unread state of emails or move emails frequently, but for the majority of users, this is actually a pretty rare task. Deleting, starting a new mail, and responding to mail dramatically overshadow these as common tasks, so we made sure these commands would always be visible. The other commands are quickly accessible via the app bar at the bottom of the screen (Windows key + Z, or swipe up from the bottom of the screen, or right-click to invoke the app bar). If you select multiple messages, we anticipate that you’re likely to use “Mark as read” or “Move,” so we automatically bring up the app bar for you. . The app bar automatically appears when you select multiple messages Message list In Release Preview, we also updated the message list to show as many messages as possible, to help you get through your email more quickly. The message list spans from the top to the bottom of the app, doesn’t show a message preview, and uses a smaller font than before. At a resolution of 1366x768, this allows you to see 14 messages instead of the 8.5 messages you could see in Consumer Preview. It’s a delicate balance to create a message list that has large enough items to work great for touch, but still provides the density that many enthusiasts expect. We also added profile pictures to the message list, so you can quickly spot messages from the people you care about most, like friends and family. This helps the message list come alive and provide a more personal experience. The profile picture comes from your friends on different social networks that you’ve connected to your Microsoft account. Reading pane The reading pane makes it fast and fluid to switch between messages, so you don’t need to go through a full page transition. The reading pane is optimized to be 640px wide so it can fit newsletters, receipts, and other commercial mail without showing a horizontal scrollbar. Also, we’ve found that when using our default reading font, 640px is the optimal width for reading a line of text so you don’t get eye fatigue or lose your place. When you receive an email we restrict the text to conform to this optimal line length, whenever possible. There is a large profile picture so it’s easy to see who sent the message. We made the subject line bold to make it stand out more in the reading pane, since it sets the context of the message. If you know on the sender or another recipient of the message via a social network that’s connected to your Microsoft account, you can tap on her name to view her profile page in the People app. From there, you can see her latest status, send an IM, etc. Writing email The screen you see when writing an email is composed of two panes, side-by-side, so that you have more room to write your message. The touch keyboard limits the amount of vertical space available, so it didn’t make sense to put the To, Cc, and other information above the body of the email. To create more space for your content, we put the To and Cc lines in one pane, and the subject and body into another. This also groups the info logically: all the information related to addressing the message is in one group, and your content is in another. The formatting commands are hidden by default to give you more space to write your email. . Writing an email Even though formatting is not used frequently in email, it is critical when you need it. To make it easier to format messages, Mail automatically shows the formatting commands when you select text in the message pane. After you apply formatting, the commands go away so you have more room to focus on what you’re writing. Our goal is to provide the right commands at the right time. When you’ve selected text, it’s most likely because you want to copy or format that text, so those options automatically come up. Many of the formatting keyboard shortcuts that you’re used to from Outlook work as well. . When writing an email, select some text and the formatting commands automatically appear above the keyboard. Designed for Windows 8 Another part of designing a great Metro style app is to make sure it takes advantage of the unique aspects of Windows 8. Mail does this by deeply integrating into the operating system to make it easier to share, print, and stay up-to-date on your email. Snap I frequently snap Mail to the side of another app (or the desktop) so that I can easily stay on top of it while I’m doing something else. It allows me to instantly see when I have new email and act on it. I can delete, move, or respond directly from the snapped Mail pane, so I can quickly get back to what I was doing. In Release Preview, you can also switch accounts and folders in the snapped state, so you can stay on top of any folder or account while you’re using another app. With these updates, it’s easy to keep the snapped view of Mail up all day long. This is really useful if you are composing a long email and need to copy and paste things into it from multiple apps. You can start a new message, snap Mail to the side, and then on the main part of the screen, switch between other apps to get everything you need and directly paste it into the message. . Mail snapped to the side of IE Print Printing is still a common need–to print a ticket, receipt, or coupon you received in email–and it’s something every Windows user expects to just work. In Release Preview, you just need to select the email you want to print, then open the Devices charm and select the printer you want to print it with. . Printing in Mail Share Mail integrates with the Share contract so that you can easily share to Mail from any app. Many times you don’t want to send something to your entire social network. Instead, you want to send a link, some photos, or a game score to just a few of your friends. Mail provides a great way to accomplish targeted, private sharing from other apps via the Share charm. If you’re sharing with the same group of people again and again, Windows remembers that group so it’s easier to share with them the next time. . Open the Share charm from IE and you’ll see a list of the people you commonly share with using Mail Mail supports sharing text, links, and pictures. If the app provides a public URL, Mail automatically grabs a picture, title, and description from the webpage. Then, you can add your message and send it to your friends. Using Mail from the Share charm looks and behaves the same as the when you compose a new message in the Mail app, so all your formatting keyboard shortcuts still work, like CTRL+B for bold. . When you share from a webpage, you can send a preview in Mail Live tiles We expect modern devices to always be up-to-date with the latest info. The Mail tile does this by rotating through the last 5 unread and unseen messages. This lets you know if there is something new since the last time you checked your email. You can also create a secondary tile for any email folder or account, and pin that to the Start screen to see live updates of new mail in just that folder or account. This is very convenient if you use server rules to automatically move email to another folder. For example, I’ve arranged Start to have separate tiles for my corporate Exchange account and my Hotmail account, so I can easily tell if I have new email in either account. . You can pin tiles to the Start screen for any email account or folder You can also put these secondary tiles on the lock screen so it’s easy to see if you have new email and what folder it’s in, without signing in to your device. . Lock screen with new mail counts for both Exchange and Hotmail If you want to know immediately when new email arrives, you can turn on notifications for each account by going to Settings, and then Accounts. . New email notification Of course, all of these are customizable, and if you prefer, you can reduce the amount of information that appears on the tiles or the lock screen. You can turn off Live tiles individually for each of your pinned folders or accounts. Notifications can be controlled for each account from the Settings charm, and include a sleep mode with several levels of silencing. Always up to date On a modern device, we just expect to have our email (and other information) always up to date. We also expect our apps to be respectful of CPU usage and battery life. Mail strikes this balance by using the background processing APIs built into Windows 8. These allow the Mail app to be suspended, but still wake up the email sync engine when new email arrives (push) or when a timer fires (polling). We’ve factored the email sync engine into a separate process so that only the minimal amount of functionality is run to keep you up to date and preserve the battery. This is what drives the Mail app’s tile and notifications. Mail has account-specific settings, so that you can choose the configuration that works best for each account on your device. By default, all accounts will download new email “as items arrive” (push), but you can configure that to happen every 15 minutes, 30 minutes, 1 hour, or manually. We want to prevent bill shock, so we try to use the minimal amount of data necessary while still delivering a great experience. One way we prevent out-of-control data usage is to only download the last 2 weeks of email by default. We’ve found that most people only actively engage with the last 2 weeks of email, so we don’t download all of the messages in your multi-gigabyte email account unless you specifically configure it that way for any given account. Also, this provides a much faster first download, so you can start acting on your messages more quickly. . Mail default account settings for Exchange If you’re on a metered network where you pay per MB of data you use, Mail uses the new networking APIs in Windows 8 to detect this, and only downloads the first 20KB of each message body and no attachments. For the majority of messages, this is the entire thing. If it’s a larger email, it’s just one tap to download the rest of the message. If you’re on Wi-Fi, the entire message is downloaded by default. What’s next Email is an important part of our daily lives. We’re still continually working to improve Mail and have many more features on the way. Today we’re excited about the response to the app and the first preview release. We believe that people want a great email app that meets their modern expectations and, based on usage, we are seeing this in the Windows 8 Mail app. Source: Windows 8 Blog
-
un error de pantalla azul en donde dice de un programa wink32.sys en windows xp
un error de pantalla azul en donde dice de un programa wink32.sys en windows xp professional service pack3 y me ocurrio despues de instalar actualizaciones de seguridad por ejemplo KB2709162, KB890830,KB2656369 y de microsoft.net framework 4 basados en x86 y microsoft.net framework sp2 windows View this thread
-
Microsoft to hold mysterious media event on June 18
What’s Microsoft announcing on Monday in Los Angeles at its hush-hush media preview? Guesses? Source: All About Microsoft
-
Why did visual studio 2010 stop compiling files with an apostrophe in their filename?
Why did visual studio 2010 stop compiling files with an apostrophe in their filename? We have a few files in one of our Visual Studio projects that contain an apostrophe in their filenames. We have been compiling those using Visual Studio 2010 projects for 12 years, at least 2 years using VS 2010. The last successful build was done on March 15, 2012. Now Visual Studio is ignoring the custom build rule altogether for those files, as if they had been marked to exclude from build, which is NOT the case. I tried inserting an apostrophe into the filename of one of our .CPP files which uses regular C++ build rules and not a custom build rule and when that is done, I get an error message when a build is started: cl : Command line error D8003: missing source filename I have tried this on more than one PC and I get identical results. The only Microsoft update that was installed since the last successful build was the March 2012 one. View the thread
-
Exposing .NET tasks as WinRT asynchronous operations
In the blog post Diving Deep with Await and WinRT, we discussed the new async and await keywords in C# and Visual Basic and how you can use them to consume Windows Runtime (WinRT) asynchronous operations. With some assistance from the .NET Base Class Libraries (BCL), you can also use these keywords to develop asynchronous operations that are then exposed via WinRT for other components built in other languages to consume. In this post, we’ll explore how to do so. (For overall details on implementing WinRT components with C# or Visual Basic, see Creating Windows Runtime Components in C# and Visual Basic.) Let’s start by reviewing the shape of asynchronous APIs in WinRT. WinRT async interfaces WinRT has several interfaces related to asynchronous operations. The first is IAsyncInfo, which every valid WinRT async operation implements. It surfaces the common capabilities for an asynchronous operation, including the operation’s current status, the operation’s error if it failed, an ID for the operation, and the operation’s ability to have cancellation requested: public interface IAsyncInfo { AsyncStatus Status { get } Exception ErrorCode { get } uint Id { get } void Cancel() void Close() } In addition to implementing IAsyncInfo, every valid WinRT asynchronous operation implements one of four additional interfaces: IAsyncAction, IAsyncActionWithProgress, IAsyncOperation, or IAsyncOperationWithProgress. These additional interfaces allow the consumer to set a callback that will be invoked when the asynchronous work completes, and optionally allow for the consumer to get a result and/or to receive progress reports: // No results, no progress public interface IAsyncAction : IAsyncInfo { AsyncActionCompletedHandler Completed { get set } void GetResults() } // No results, with progress public interface IAsyncActionWithProgress : IAsyncInfo { AsyncActionWithProgressCompletedHandler Completed { get set } AsyncActionProgressHandler Progress { get set } void GetResults() } // With results, no progress public interface IAsyncOperation : IAsyncInfo { AsyncOperationCompletedHandler Completed { get set } TResult GetResults() } // With results, with progress public interface IAsyncOperationWithProgress : IAsyncInfo { AsyncOperationWithProgressCompletedHandler Completed { get set } AsyncOperationProgressHandler Progress { get set } TResult GetResults() } (IAsyncAction provides a GetResults method even though there are no results to be returned. This provides a method on a faulted async operation to throw its exception, rather than forcing all consumers to access the IAsyncInfo’s ErrorCode property. It is similar to how awaiter types in C# and Visual Basic expose a GetResult method, even if that GetResult method is typed to return void.) When building a WinRT library, all publicly exposed asynchronous operations in that library are strongly typed to return one of these four interfaces. In contrast, new asynchronous operations exposed from .NET libraries follow the Task-based Asynchronous Pattern (TAP), returning Task or Task, the former for operations that don’t return a result, and the latter for operations that do. Task and Task don’t implement these WinRT interfaces, nor does the Common Language Runtime (CLR) implicitly paper over the differences (as it does do for some types, such as the WinRT Windows.Foundation.Uri type and the BCL System.Uri type). Instead, we need to explicitly convert from one world to the other. In the Diving Deep with Await and WinRT post, we saw how the AsTask extension method in the BCL provides an explicit cast-like mechanism to convert from the WinRT async interfaces to .NET Tasks. The BCL also supports the other direction, with methods to convert from .NET Tasks to the WinRT async interfaces. Converting with AsAsyncAction and AsAsyncOperation For the purposes of this blog post, let’s assume we have a .NET asynchronous method DownloadStringAsyncInternal. We pass to it a URL to a web page, and the method asynchronously downloads and returns the contents of that page as a string: internal static Task DownloadStringAsyncInternal(string url) How this method is implemented doesn’t matter. Rather, our goal is to wrap this as a WinRT asynchronous operation, meaning as a method that returns one of the four previously mentioned interfaces. As our operation has a result (a string) and as it doesn’t support progress reporting, our WinRT async operation returns IAsyncOperation: public static IAsyncOperation DownloadStringAsync(string url) To implement this method, we can call the DownloadStringAsyncInternal method to get the resulting Task. Then we need to convert that task to the required IAsyncOperation… but how? public static IAsyncOperation DownloadStringAsync(string url) { Task from = DownloadStringAsyncInternal(url) IAsyncOperation to = ... // TODO: how do we convert 'from'? return to } To address this gap, the System.Runtime.WindowsRuntime.dll assembly in .NET 4.5 includes extension methods for Task and Task that provide the necessary conversions: // in System.Runtime.WindowsRuntime.dll public static class WindowsRuntimeSystemExtensions { public static IAsyncAction AsAsyncAction( this Task source) public static IAsyncOperation AsAsyncOperation( this Task source) ... } These methods return a new IAsyncAction or IAsyncOperation instance that wraps the supplied Task or Task, respectively (because Task derives from Task, both of these methods are available for Task, though it’s relatively rare that you would use AsAsyncAction with a result-returning asynchronous method). Logically, you can think of these operations as explicit, synchronous casts, or from a design pattern perspective, as adapters. They return an instance that represents the underlying task but that exposes the required surface area for WinRT. With such extension methods, we can complete our DownloadStringAsync implementation: public static IAsyncOperation DownloadStringAsync(string url) { Task from = DownloadStringAsyncInternal(url) IAsyncOperation to = from.AsAsyncOperation() return to } We can also write this more succinctly, highlighting how very cast-like the operation is: public static IAsyncOperation DownloadStringAsync(string url) { return DownloadStringAsyncInternal(url).AsAsyncOperation() } DownloadStringAsyncInternal is being invoked before we ever call AsAsyncOperation. This means that we need the synchronous call to DownloadStringAsyncInternal to return quickly to ensure that the DownloadStringAsync wrapper method is responsive. If for some reason you fear the synchronous work you’re doing will take too long, or if you explicitly want to offload the invocation to a thread pool for other reasons, you can do so using Task.Run, then invoking AsAsyncOperation on its returned task: public static IAsyncOperation DownloadStringAsync(string url) { return Task.Run(()=>DownloadStringAsyncInternal(url)).AsAsyncOperation() } More flexibility with AsyncInfo.Run These built-in AsAsyncAction and AsAsyncOperation extension methods are great for simple conversions from Task to IAsyncAction and from Task to IAsyncOperation. But what about more advanced conversions? System.Runtime.WindowsRuntime.dll contains another type that provides more flexibility: AsyncInfo, in the System.Runtime.InteropServices.WindowsRuntime namespace. AsyncInfo exposes four overloads of a static Run method, one for each of the four WinRT async interfaces: // in System.Runtime.WindowsRuntime.dll public static class AsyncInfo { // No results, no progress public static IAsyncAction Run( Func Task> taskProvider) // No results, with progress public static IAsyncActionWithProgress Run( Func IProgress, Task> taskProvider) // With results, no progress public static IAsyncOperation Run( Func Task> taskProvider) // With results, with progress public static IAsyncOperationWithProgress Run( Func IProgress, Task> taskProvider) } The AsAsyncAction and AsAsyncOperation methods we’ve already examined accept a Task as an argument. In contrast, these Run methods accept a function delegate that returns a Task, and this difference between Task and Func is enough to give us the added flexibility we need for more advanced operations. Logically, you can think of AsAsyncAction and AsAsyncOperation as being simple helpers on top of the more advanced AsyncInfo.Run: public static IAsyncAction AsAsyncAction( this Task source) { return AsyncInfo.Run(_ => source) } public static IAsyncOperation AsAsyncOperation( this Task source) { return AsyncInfo.Run(_ => source) } This isn’t exactly how they’re implemented in .NET 4.5, but functionally they behave this way, so it helps to think about them as such to contrast between the basic and advanced support. If you have a simple case, use AsAsyncAction and AsAsyncOperation, but there are several advanced cases where AsyncInfo.Run shines. Cancellation AsyncInfo.Run makes it possible to support cancellation with WinRT async methods. To continue with our downloading example, let’s say we have another DownloadStringAsyncInternal overload that accepts a CancellationToken: internal static Task DownloadStringAsyncInternal( string url, CancellationToken cancellationToken) CancellationToken is .NET Framework type that supports cooperative cancellation in a composable manner. You can pass a single token into any number of method calls, and when that token has cancellation requested (via the CancellationTokenSource that created the token), the cancellation request is then visible to all of those consuming operations. This approach differs slightly from that used by WinRT async, which is to have each individual IAsyncInfo expose its own Cancel method. Given that, how do we arrange for a call to Cancel on the IAsyncOperation to have cancellation requested on a CancellationToken that’s passed into DownloadStringAsyncInternal? AsAsyncOperation won’t work in this case: public static IAsyncOperation DownloadStringAsync(string uri) { return DownloadStringAsyncInternal(uri, … /* what goes here?? */) .AsAsyncOperation() } To know when cancellation is requested of the IAsyncOperation, that instance would need to somehow notify a listener that its Cancel method was called, for example by requesting cancellation of a CancellationToken that we’d pass into DownloadStringAsyncInternal. But in a classic “catch-22,” we don’t get the Task on which to invoke AsAsyncOperation until we’ve already invoked DownloadStringAsyncInternal, at which point we would have already needed to supply the very CancellationToken we’d have wanted AsAsyncOperation to provide. There are multiple ways to solve this conundrum, including the solution employed by AsyncInfo.Run. The Run method is responsible for constructing the IAsyncOperation, and it creates that instance to request cancellation of a CancellationToken that it also creates when the async operation’s Cancel method is called. Then when invoking the user-supplied delegate passed to Run, it passes in this token, avoiding the previously discussed cycle: public static IAsyncOperation DownloadStringAsync(string uri) { return AsyncInfo.Run(cancellationToken => DownloadStringAsyncInternal(uri, cancellationToken)) } Lambdas and Anonymous Methods AsyncInfo.Run simplifies using lambda functions and anonymous methods to implement WinRT async methods. For example, if we didn’t already have the DownloadStringAsyncInternal method, we might implement it and DownloadStringAsync like this: public static IAsyncOperation DownloadStringAsync(string uri) { return AsyncInfo.Run(delegate(CancellationToken cancellationToken) { return DownloadStringAsyncInternal(uri, cancellationToken)) }) } private static async Task DownloadStringAsyncInternal( string uri, CancellationToken cancellationToken) { var response = await new HttpClient().GetAsync( uri, cancellationToken) response.EnsureSuccessStatusCode() return await response.Content.ReadAsStringAsync() } By taking advantage of the C# and Visual Basic support for writing asynchronous anonymous methods, we can simplify our implementation by combining these two methods into one: public static IAsyncOperation DownloadStringAsync(string uri) { return AsyncInfo.Run(async delegate(CancellationToken cancellationToken) { var response = await new HttpClient().GetAsync( uri, cancellationToken) response.EnsureSuccessStatusCode() return await response.Content.ReadAsStringAsync() }) } Progress AsyncInfo.Run also provides support for progress reporting through WinRT async methods. Instead of our DownloadStringAsync method returning an IAsyncOperation, imagine if we instead wanted it to return an IAsyncOperationWithProgress: public static IAsyncOperationWithProgress DownloadStringAsync(string uri) DownloadStringAsync now can provide progress updates containing integral data, such that consumers can set a delegate as the interface’s Progress property to receive notifications of progress change. AsyncInfo.Run provides an overload that accepts a Func,Task>. Just as AsyncInfo.Run passes into the delegate a CancellationToken that will have cancellation requested when the Cancel method is called, it can also pass in an IProgress instance whose Report method triggers invocations of the consumer’s Progress delegate. For example, if we wanted to modify our previous example to report 0% progress at the beginning, 50% progress after getting the response back, and 100% progress after parsing the response into a string, that might look like this: public static IAsyncOperationWithProgress DownloadStringAsync(string uri) { return AsyncInfo.Run(async delegate( CancellationToken cancellationToken, IProgress progress) { progress.Report(0) try { var response = await new HttpClient().GetAsync(uri, cancellationToken) progress.Report(50) response.EnsureSuccessStatusCode() return await response.Content.ReadAsStringAsync() } finally { progress.Report(100) } }) } A look under the cover To get a good mental model for how all of this works, let’s explore an implementation of AsAsyncOperation and AsyncInfo.Run. These are not the same implementations that exist in .NET 4.5, and they aren’t as robust. Rather, they are approximations that provide a good sense of how things work under the cover, and are not intended to be used in production. AsAsyncOperation The AsAsyncOperation method takes a Task and returns an IAsyncOperation: public static IAsyncOperation AsAsyncOperation( this Task source) To implement this method, we need to create a type that implements IAsyncOperation and that wraps the supplied task. public static IAsyncOperation AsAsyncOperation( this Task source) { return new TaskAsAsyncOperationAdapter(source) } internal class TaskAsAsyncOperationAdapter : IAsyncOperation { private readonly Task m_task public TaskAsAsyncOperationAdapter(Task task) { m_task = task } ... } Each of the interface method implementations on this type will delegate to functionality on the wrapped task. Let’s start with the easiest members. First, the IAsyncInfo.Close method is supposed to aggressively clean up any resources that the completed asynchronous operation used. As we have no such resources (our object just wraps a task), our implementation is empty: public void Close() { /* NOP */ } With the IAsyncInfo.Cancel method a consumer of the async operation can request its cancellation. It is purely a request, and doesn’t in any way force the operation to exit. We simply use a CancellationTokenSource to store that a request occurred: private readonly CancellationTokenSource m_canceler = new CancellationTokenSource() public void Cancel() { m_canceler.Cancel() } The IAsyncInfo.Status property returns an AsyncStatus to represent the current status of the operation with regards to its asynchronous lifecycle. This can be one of four values: Started, Completed, Error, or Canceled. For the most part, we can simply delegate to the underlying Task’s Status property and map from its returned TaskStatus to the needed AsyncStatus: From TaskStatus To AsyncStatus RanToCompletion Completed Faulted Error Canceled Canceled All other values & cancellation was requested Canceled All other values & cancellation was not requested Started If the Task is not yet completed and cancellation has been requested, we need to return Canceled instead of Started. This means that although TaskStatus.Canceled is only a terminal state, AsyncStatus.Canceled can be either a terminal state or a non-terminal state, in that it’s possible for an IAsyncInfo to end in the Canceled state, or for an IAsyncInfo in the Canceled state to transition to either AsyncStatus.Completed or AsyncStatus.Error. public AsyncStatus Status { get { switch (m_task.Status) { case TaskStatus.RanToCompletion: return AsyncStatus.Completed case TaskStatus.Faulted: return AsyncStatus.Error case TaskStatus.Canceled: return AsyncStatus.Canceled default: return m_canceler.IsCancellationRequested ? AsyncStatus.Canceled : AsyncStatus.Started } } } The IAsyncInfo.Id property returns a UInt32 identifier for the operation. As Task itself already exposes such an identifier (as an Int32), we can implement this property simply by delegating through to the underlying Task property: public uint Id { get { return (uint)m_task.Id } } WinRT defines the IAsyncInfo.ErrorCode property to return an HResult. But the CLR internally maps the WinRT HResult to a .NET Exception, surfacing it that way to us through the managed projection. Task itself exposes an Exception property, so we can just delegate through to it: if the Task ended in the Faulted state, we return its first exception (a Task could potentially fault due to multiple exceptions, such as with a Task returned from Task.WhenAll), returning null otherwise: public Exception ErrorCode { get { return m_task.IsFaulted ? m_task.Exception.InnerException : null } } That’s it for implementing IAsyncInfo. Now we need to implement the two additional members supplied by IAsyncOperation: GetResults and Completed. Consumers call GetResults after the operation completes successfully or after an exception occurs. In the former case, it returns the computed result, and in the latter case, it throws the relevant exception. If the operation ended as Canceled, or if it hasn’t ended yet, it’s illegal to invoke GetResults. As such, we can implement GetResults as follows, relying on the task’s awaiter’s GetResult method to return the result if successful or to propagate the right exception if the task ended as Faulted. public TResult GetResults() { switch (m_task.Status) { case TaskStatus.RanToCompletion: case TaskStatus.Faulted: return m_task.GetAwaiter().GetResult() default: throw new InvalidOperationException("Invalid GetResults call.") } } Finally, we have the Completed property. Completed represents a delegate that should be invoked when the operation completes. If the operation has already finished when Completed is set, the supplied delegate must be invoked or scheduled immediately. Additionally, a consumer can set the property only once (attempts to set multiple times result in exceptions). And after the operation has been completed, implementations must drop the reference to the delegate to avoid memory leaks. We can rely on Task’s ContinueWith method to implement much of this behavior, but because ContinueWith can be used multiple times on the same Task instance, we need to manually implement the more restrictive “set once” behavior: private AsyncOperationCompletedHandler m_handler private int m_handlerSet public AsyncOperationCompletedHandler Completed { get { return m_handler } set { if (value == null) throw new ArgumentNullException("value") if (Interlocked.CompareExchange(ref m_handlerSet, 1, 0) != 0) throw new InvalidOperationException("Handler already set.") m_handler = value var sc = SynchronizationContext.Current m_task.ContinueWith(delegate { var handler = m_handler m_handler = null if (sc == null) handler(this, this.Status) else sc.Post(delegate { handler(this, this.Status) }, null) }, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default) } } With that, our implementation of AsAsyncOperation is complete, and we can use any Task-returning method as an IAsyncOperation method. AsyncInfo.Run Now, what about the more advanced AsyncInfo.Run? public static IAsyncOperation Run( Func taskProvider) To support this Run overload, we can use the same TaskAsAsyncOperationAdapter type we just created, with all of our existing implementation intact. In fact, we just need to augment it with the ability to work in terms of Func instead of only in terms of Task. When such a delegate is provided, we can simply invoke it synchronously, passing in the m_canceler CancellationTokenSource we defined earlier and storing the returned task: internal class TaskAsAsyncOperationAdapter : IAsyncOperation { private readonly Task m_task public TaskAsAsyncOperationAdapter(Task task) { m_task = task } public TaskAsAsyncOperationAdapter( Func func) { m_task = func(m_canceler.Token) } ... } public static class AsyncInfo { public static IAsyncOperation Run( Func taskProvider) { return new TaskAsAsyncOperationAdapter(taskProvider) } … } This implementation highlights that there’s no magic happening here. AsAsyncAction, AsAsyncOperation, and AsyncInfo.Run are all just helper implementations that save you from having to write all of this boilerplate yourself. Conclusion At this point, I hope you have a good understanding of what AsAsyncAction, AsAsyncOperation, and AsyncInfo.Run do for you: they make it easy to take a Task or a Task, and expose it as an IAsyncAction, an IAsyncOperation, an IAsyncActionWithProgress, or an IAsyncOperationWithProgress. Combined with the async and await keywords in C# and Visual Basic, this makes it very easy to implement new WinRT asynchronous operations in managed code. As long as the functionality you’re exposing is available as a Task or Task, you should rely on these built-in capabilities to do the conversions for you instead of implementing the WInRT async interfaces manually. And if the functionality you’re trying to expose is not available yet as a Task or Task, try to expose it as a Task or Task first, and then rely on the built-in conversions. It can be quite difficult to get all of the semantics around a WinRT asynchronous interface implementation correct, which is why these conversions exist to do it for you. Similar support also exists if you’re implementing WinRT asynchronous operations in C++, whether through the base AsyncBase class in the Windows Runtime Library, or through the create_async function in the Parallel Pattern Library.
-
Old driver won't work
I have a 6 year old Canon M&5750 multi use printer/scanner/fax/copier. Great machine. I just purchase a new PC utilizing Windows 7. This os, being a 64 bit os, will not support the drivers for my older canon. I was able to find a driver online which I purchased, for operating the scanner. Now the unit will not print? Any ideas? View the thread
-
window XP 32 bit max expandable dram
Need to know if I can upgrade my dram from 512MB to i GB in my 2.4 GHz pentium 4 CPU ? View this thread
-
The Sims 1 (Original) HELP!!
I have just brought the original sims 1 again and am trying to install in on my acer laptop. When i insert the disc the auto run menu appears, i then click setup but nothing happens what so ever, nothing else pops up on the screen or does anything. I am running Vista Home Basic. Can anyone help?? Please!! View this thread
-
set a vacation message response on microsoft exchange?
I can not find the setting to put a vacation message on outlook express, where do I go to find the application? View this thread
-
Can I reinstall (fresh install) my Win7 OS using the same product key on the same Machine? Is it pos
My laptop is getting slower (Not that slow, but not that fast as well). My utilities didn't help me to speed this up so I decided to re-install my OS (I'm planning this even before this problem occured). I haven't tried this procedure and I'm afraid that if I did this, I won't have luck on activating so I tried asking it here. Please help. Thanks! View the thread
-
Microsoft System Center 2012
Posted on The Operations of Cloud Computing[/b] What this means is that Cloud computing transforms the way enterprises provide and consume IT services with the promise of more productive infrastructure and more predictable applications. [url=http://www.everything-microsoft.com/2012/06/14/microsoft-system-center-2012-2/the-cloud/" rel="attachment wp-att-94593">http://cdn8.everything-microsoft.com/wp-content/uploads/2012/06/The-Cloud-400x263.jpg?9d7bd4 Business users see cost savings and flexibility when they consume IT as a Service—a service that they self-allocate through a portal, that scales up or down according to their needs, and that they pay for based on use. Consider that most companies cannot afford to upgrade to the latest operating system because that would also involve upgrading to more sophisticated and expensive hardware. But with the Cloud operations, the latest software and hardware is automatically provided, so the upgrade costs are never there. Datacenter administrators will see cost savings by pooling shared resources together into a private cloud that serves multiple business users who consume only what they need. Flexibility will come through leveraging public cloud resources to complement on-premises capacity. So if you need it you use it, if you don’t, you won’t. All of this provides cost controls that you can manage. [url=http://www.everything-microsoft.com/2012/06/14/microsoft-system-center-2012-2/">Microsoft System Center 2012 was posted on [url=http://www.everything-microsoft.com">Everything Microsoft - Latest Microsoft News, Guides, Reviews & Themes. If you are not reading this content in an email newsletter, it is being used without permission. View the full article
-
Three more reasons Microsoft might buy Yammer
Rumors are flying that Microsoft might buy enterprise social networking vendor Yammer, maybe as soon as this week. Here’s why this wouldn’t surprise me. Source: All About Microsoft
-
How can I trace the IP of "Remote shutdown" source machine?
HI, I have enable shutdown event log in my XP machine however still I am not able to trace the IP of on of 15 XP work-group machine which remotely shutting down my machine. The command which might have been used is: shutdown /f /r /m \ /t: 0 Can any one suggest me how trace that remote machine IP ? Or at least tell me which protocol or port shutdown.exe uses when it sends remote command. I have captured ProcMon, NetMon and Wire-Shark log, still I have no clue to start my investigation. Please help. View this thread
-
Win7 Home Edition 64-bit to Windows 7 Professional
I need info on how do I upgrade to Windows 7 Professional if I buy the upgrade at Wal-Mart? Is there anything special I need to know before I go this route. Thanks. View the thread
-
"operation cancel due to restrictions in effect on this computer"
when I hld down the CTRL button and hoover oever a hyperling in word 2007 this errror messagr pops up nad exploere doesn't open and go to the linke page. I ues the link is broken and requires administrator interevention, however I am the administrator and have o idea what to do View the thread
-
Cannot download/install update KB2656373
I had gotten the update tonight along with others, the other updates were fine, but this one did not work, So I tried the microsoft fixit program, and it found that it was an update issue, and it tried to fix it, after it was done I attempted to retry the install, still did not work, so I did a clean boot as one of the guides said and tried both again, did not work. Then I found the install itself on the microsoft download list, downloaded it and tried to install it but it said it could not install. I keep getting the code 8024200D, but that has yet to help me. I have Windows 7 My computer came preinstalled with windows 7 home, but I upgraded to ultimate. If that is needed. View the thread
-
Outlook Express
I am not able to open Outlook Express in Windows 7 Ultimate? When I type the command "msimn", it gives the error ' Windows cannot find 'msimn'. Make sure you typed the name correctly, and then try again.' View the thread
-
My Windows Vista Business Service Pack 2 won't create desktop.ini files anymore.
Original Title: Vista won't create desktop.ini Last week I noticed my computer running Vista Business SP2 won't create desktop.ini files anymore. So if I want to set a folder template to Pictures or Music, it won't keep the change because the desktop.ini file isn't created. I've been searching around and only found people who want to disable the creation of the file, with no solution. Any help how to enable it? View this thread