C# MRDS: Why are the handlers virtual?

Can somebody familiar with microsoft robotics studio please explain why the handler operations are virtual and some are set as non-virtual ?

[ServiceHandler(ServiceHandlerBehavior.Concurrent)] public virtual IEnumerator<ITask> GetHandler(Get get) { get.ResponsePort.Post(_state); yield break; }

vs

[ServiceHandler(ServiceHandlerBehavior.Concurrent)] public IEnumerator<ITask> SubscribeHandler(Subscribe subscribe) { SubscribeRequestType request = subscribe.Body; LogInfo("Subscribe request from: " + request.Subscriber); // Use the Subscription Manager to handle the subscribers yield return Arbiter.Choice( SubscribeHelper(_submgrPort, request, subscribe.ResponsePort), delegate(SuccessResult success) { // Send a notification on successful subscription so that the // subscriber can initialize its own state base.SendNotificationToTarget<Replace>(request.Subscriber, _submgrPort, _state); }, delegate(Exception e) { LogError(null, "Subscribe failed", e); } ); yield break; }

Thanks in advance.

--------------Solutions-------------

Virtual handlers are used in classes you expect to use as base for other classes. Handlers that are not virtual are either declared as overrides in derived classes, or in classes that will not be derived (as is often the case in sample code).

Refer to the following articles:

http://msdn.microsoft.com/en-us/library/9fkccyh4(v=VS.100).aspx

What are Virtual Methods?

C# virtual methods question

Should virtual methods be explicitly overridden in C#?

Category:c# 3.0 Time:2011-09-01 Views:0

Related post

  • Message Map in Win32 No-MFC 2009-12-07

    How could I create similar structure to handle Win32 Messages like it is in MFC? In MFC; BEGIN_MESSAGE_MAP(CSkinCtrlTestDlg, CDialog) //{{AFX_MSG_MAP(CSkinCtrlTestDlg) ON_BN_CLICKED(IDC_BROWSE, OnBrowse) ON_BN_CLICKED(IDC_DEFAULTSKIN, OnChangeSkin) O

  • Basing XAML on UserControl 2011-08-05

    I'm still only about ankle deep into SL so hope this is something simple I'm missing... I've got a need for two (someday more) Silverlight controls that primarily exist to display somewhat similar data grids but much of the same codebehind wiring wil

  • IIS 6 ASP.NET handlers not working in virtual application 2011-01-13

    I have a virtual directory (configured as an application). It will accept requests for all files that exist, but it will not call handlers (system.web/httpHandlers). Any ideas? <httpHandlers> <remove verb="*" path="*.asmx"/> <add verb=

  • attaching handlers to virtual controls in jQuery 2010-09-09

    Here is what i'm trying to accomplish.... I need to be able to register elements that aren't part of the DOM when they are created. here is the syntax i'm trying to synthesize $(document).ready(function(){ $('#virtualControl').registerControl(functio

  • How to translate a virtual memory address to a physical address? 2008-12-14

    In my C++ program (on Windows), I'm allocating a block of memory and can make sure it stays locked (unswapped and contiguous) in physical memory (i.e. using VirtualAllocEx(), MapUserPhysicalPages() etc). In the context of my process, I can get the VI

  • How virtual events work in C#? 2009-04-03

    Below is the program I used for the test. It prints (as expected): Raise A Event from A Raise B Event from B Now, if we change first two lines of the Main to be: A a = new B(); B b = new B(); the Program will print: Raise A Raise B Event from B which

  • My HttpHandler doesn't work with a virtual directory in IIS7, but using cassini it does? 2009-08-20

    My httphandler does not work in IIS7 (virutal directory), but using cassini it works. It used to work on my windows xp IIS also. What could be the cause of this? I am getting a 404 not found error when trying to access the httphandler's page. -------

  • Should I unit test event handlers 2009-08-27

    I tend to veer towards the opinion that only public interfaces should be tested, thereby covering testing of private procedures. However, an interesting question arose yesterday - should one test event handlers? My gut instinct is that logic should b

  • ELMAH looking for binaries on Virtual director 2009-09-03

    I have a virtual directory just above the root of my web app that I use to store product images. After I installed ELMAH for logging I realized images stopped working. This was due to ELMAH looking for its dll under productimages/bin folder. After i

  • Performance problem Loading Dataset inside a virtual 2009-10-07

    Host Configuration: HP EliteBook 8530w 4G Ram Win7 Ultimate 64Bit RC SQL Server 2005 64bit Developer Edition Virtual: Windows Virtual PC 1G Ram allocated Integration Services installed Windows XP 64bit Up to date service packs and .Net framework thro

  • httphandler filetype mapping requires virtual directory (or does it?) 2009-10-21

    I am using an httpHandler to pass all requests for *.gif files to an ashx handler. i only want to do this for requests to a sub-folder within the website. The website root is called 'demo' and the subfolder is called et. So, I add a web.config file t

  • c# form inheritance event handlers fire twice 2010-01-21

    I inherit from a root form that has a next and back button in, then use these buttons on some subforms and get the buttons called twice, i beleive the problem to be outlined in the MSDN here: http://msdn.microsoft.com/en-us/library/e33683a5(VS.71).as

  • JavaScript Event Listeners vs Event Handlers 2010-02-07

    Ok, I have been trying to figure this out for a long time now and finally have the time to investigate. As the title suggests "what is the difference"? I know that this works the way I want it to. addLoadEvent(converter); // Converter function conver

  • WPF Two Commands handlers, One Command 2010-03-15

    Im deriving from a third party control. It is implementing ApplicationCommands.SelectAll. However the behaviour i want is slightly different. there is no virtual method i can override, and when i register a class handler, like so CommandManager.Regis

  • Cannot add rows when the DataGridView control is in virtual mode? 2010-04-07

    When I try to add a new row to a DataGridView in virtual mode like this: dataGridViewX1.Rows.Add(new string[] { "Parker", "Seattle" }); The following exception occurs: Operation is not valid when the DataGridView control is in virtual mode? ---------

  • Cocoa Virtual Keystrokes Pain 2010-04-19

    I'm writing an application to respond on a hotkey by copying highlighted text into NSPasteboard's generalPasteboard. After looking around here for a solution for sending virtual keystrokes, I found this: http://stackoverflow.com/questions/1505933/how

  • ASP.NET MVC thinks my virtual directory is a controller 2010-04-28

    I have a virtual directory under my MVC website in IIS called "Files". This directory is at the same level as my Views directory. When I link to a file from my MVC app to a file under my Files directory, I get the following error: The controller for

  • How do I set a single virtual directory of my web app to not inherit web.config? 2010-05-26

    I have a virtual directory setup in one of my web apps that needs to not inherit the web.config of the main app so it can run on it's own. I am wondering how I can do this because right now when I hit it (mainwebapp.domain.com/virdir) it throws an er

  • Scrolling to selected element while typing on iphone safari virtual keyboard 2010-06-01

    I am building an iphone webapp and have a page with an input field. I'd like the field to scroll up to just above the virtual keyboard when it shows up. I've tried putting a scrollTo(x,y) on the input focus event (i.e. just before the keyboard shows

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.437 (s). 13 q(s)