Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 942935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:21:10+00:00 2026-05-15T22:21:10+00:00

I am working on an WPF application that uses a BusinessLogic layer (currently a

  • 0

I am working on an WPF application that uses a BusinessLogic layer (currently a single dll) in which I created my BL methods that will be called directly from the UI. Each BL manager is resolved with Unity (thinking on switching to MEF though…). BL classes implements a specific interface that have of course apropriate methods.

Now, what I want is to create (or rather to GENERATE) a new asynchronous-aspect-like assembly (or more…) that should have similar methods/operations defined as in my original assembly (the same parameters…) and also a callback delegate as a parameter.
So basically I want async methods to be generated with some framework out there…

Besides the usual call to:
User userBO = Resolve().Login(“name”, “pass”);
I’d like to use something similar with:
Resolve().Login(“name”, “pass”, delegate(object, SomeArgs e) { User userBO = e.Args….};

Now, I want this assembly to be generated instead of writing new eventArgs and delegates for each method.
I am aware that PostSharp could help in AOP task, but I coulnd’t find anything regarding this code generation mechanism in a new dll for asynchronous methods.

Is there a way to achieve this using a third party tool or do I have to rewrite the whole async thing manually?

Any ideas are welcome.
Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:21:11+00:00Added an answer on May 15, 2026 at 10:21 pm

    I’m not aware of a tool that will do this for you, but there’s an easy way to wrap them in Task objects. This is easier at least than manually defining Async methods and event callbacks.

    The general concept is to run the method as a Task and then schedule a task continuation to the UI thread.

    First, define a scheduler (you don’t need to do this every time; it could be a global var or a window-level var):

    TaskScheduler ui = TaskScheduler.FromCurrentSynchronizationContext();
    

    then when you want to call a method and handle its return value:

    var bll = Resolve();
    Task.Factory.StartNew(_ => bll.Login("name", "pass"))
      .ContinueWith(task =>
      {
        // Note: accessing Result will raise any exceptions thrown by Login
        User userBO = task.Result;
        ...
      }, ui);
    

    It’s not quite as pretty as your suggested syntax, but it’s usable. The task continuation passed to ContinueWith will run on the UI thread, so it is safe to update the UI or any databound objects.

    Task objects also fully support other common asynchronous scenarios, in particular cancellation and progress reporting.

    Since this approach doesn’t actually add events to the class, it should be possible to write a T4 template to generate extension methods for you (e.g., LoginTask(string username, string password, Action<Task<User>> continuation)).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a WPF application which has a treeview that represents an
I'm working on a WPF application that sometimes exhibits odd problems and appears to
I'm working on a WPF application and is using the Model-View-ViewModel pattern. The application
I'm working on a simple application to start learning my way around WPF. I
I am working on a graph in WPF, in each section there are thousands
I have a WPF form and I am working with databinding. I get the
I'm working through the Data Binding chapter in Pro WPF in C# 2008. They
Been trying to find a working implementation of a WPF listview (or listbox) where
I'm creating an WPF app, so I'm mostly working with the ImageSource class for
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.