Good practice for async databinding, regarding entity-framework.

I have some issue to find a good pattern to keep my UI responsive using asynch databinding and entity framework which is not thread-safe. It would be a shame if the UI came to totaly freeze with no feedback for a connection lost.
So, entity framework is not thread-safe. Which mean I won't be able to rely on lazy loading here and involve than if I do async databinding to a collection of object, each object will have to load their navigations properties with their own context to display
data. Ok, I can handle this. But what if I need more than displaying data and I want to modify a navigation property ?
I need when I set the navigation property in my viewmodel to attach an entity from the same context than the parent entity is from. So here I have one context for multiple thread. What do I do ? =(
Does anyone have some experience in it and can help me to clear this mess from my mind ? =D
All the sample I can find about async databinding don't go any further than make a Thread.Sleep before returning a string, it's not realy helpfull.

There are reasons people post simple explanations.
One of those is because they post blog entries when they're learning something rather than when they are expert in it.  The blog post is part of their learning process.
I sometimes share context. 
What I do is put the context in Application.Current.Resources and then go get it from there when I need to re-use that particular one.
xxxDomainContext DBContext = new xxxDomainContext();
Application.Current.Resources.Add("DBContext", DBContext);
and using that:
context = (xxxxDomainContext)Application.Current.Resources["DBContext"];
You can alternatively share collections in a similar way.  Depends on how many related tables you have, but reading a whole tree of static data is sometimes a good idea rather than just one table at a time.
One technique I use is to cache slowly changing data on the client and then go get changes since the last run off the server.  For a fair few applications, yesterdays data is good enough for most data sets.  It's just the odd one or two which you really
need up to date numbers or whatever.
You can see a collection shared in this sample ( but the sharing is for different reasons ) :
 https://gallery.technet.microsoft.com/Dynamic-XAML-Composed-View-e087f3c1
Please don't forget to upvote posts which you like and mark those which answer your question.
My latest Technet article - Dynamic XAML

Similar Messages

  • Good Practice for managing player high scores & other stats

    During PC based game development, what is a good practice for saving high scores, game history etc for multiple users in terms of the following attributes :
    file types, data types to be used in the file, file protection from manual editing etc.
    pls throw some advice on the popular industry practice in use.
    regards, bittu ch

    During PC based game development, what is a good practice for saving high scores, game history etc for multiple users in terms of the following attributes :
    file types, data types to be used in the file, file protection from manual editing etc.
    pls throw some advice on the popular industry practice in use.
    regards, bittu ch

  • What is good practice for playing multiple video's in a single swf?

    Hello,
    I have build in the past a video wall with video's inside. After building this i came across some problems.
    If you have too many video players loading at once it takes a lot of processing and the tweens in the
    page while loading the video's where not moving fluidly, but more in a stuttering way.
    After lot's of test i found a good working solution.  I imported the flv video's into flash en exported them on the timeline
    as a embedded swf.  Then i externally loaded these swf files and that performed much better.
    Is it even good practice to load multiple video instances at once? I used this time the LoaderMax of greensock but the video's
    only play after it's completely loaded. I would like to find a way to progressive play all video's at.
    Does someone has experience with this?
    Regards,
    Chris.

    How about an XML file which supplies the title for each movie and the location or source of the video to be played?  Simple version below.
    <?xml version="1.0" ?>
    - <playlist>
    <video src="Gfx/video/Alex1.f4v" title="John Deere 330" />
    <video src="Gfx/video/Benni1.f4v" title="Hitachi Z240F" />
    <video src="Gfx/video/Scotti1.f4v" title="Hitachi Z350F" />
    <video src="Gfx/video/Scotti2.f4v" title="Hitachi Z350F" />
    </playlist>
    JR

  • WHAT IS SAP  " GOOD PRACTICE" FOR TESTING PROCEDURES ?

    Dear Gurus, could you please share with me the good practice of testing procedures? I am a 1st level fico support and being asked for this. Thanks in advance for your kindest help.

    Hi,
    Please use the below links FYR...
    http://help.sap.com/erp2005_ehp_02/helpdata/en/2f/75ba3bd14a6a6ae10000000a114084/content.htm
    http://www.ebooksquad.com/search/SAPmoduletesting+procedures
    With Regards,
    Lolla.

  • Good or Bad: Repository pattern with Entity framework??

    Suggestions about not to use enttity framework because:
    1) entity framework is itself a Repository pattern
    2) So, what the use of having one more repository pattern over an exisitng repositroy pattern (i.e Entity framework)
    Please suggest.
    Thanks in advance!!

    I've used both nHibernate and the Entity Framework 6 and nHibernate wins hands down as the best orm, despite it's learning curve. ORMs can be massive timesavers as you don't end up writing boiler plate db access code.
    I used 3 different versions on nHibernate over the years. I didn't paticulalry care for any version of nHibernate. I much prefer EF over nHibernate any day of the week, month or year.
    Unlike the previous responder I disagree with testability, each repository should have it's own interface. And if implemented correctly it can save tones of time as you need only mock one or two repository methods rather than 10s or 100s of database
    gateway call using one class per table.
    What? Like a  DAO can't  have an interface, which is just as testable as any repository pattern using an interface when using a test harnerss and testproject to test the DAO? And one has to go beyond some generic repository pattern in
    unit, functional and intergation testing when it comes to data access. 
    Unlike you, I want complete control of the object all aspects of it even in its usage of other DAO(s) that could or would be used, which the  repository pattern doesn't cut it for me. 
    Like I said, I'll take EF over nHibernate, which is much like talking MS SQL Server over Oracle with Oracle being a PITA to work with it.

  • Good practices for ECC 6.0 wr.t. internal tables..

    hi,
    i am told that when defining internal tables in ecc 6.0, we shud avoid using OCCURS and WITH HEADER LINE.  and always use work areas..
    is this right ? is this a good practice or a must ?
    i followed this and created an internal table without a header line .then i  am using a collect statement in my programn which fails and says that IT is not with header line !!
    COLLECT ITT.
    what to do ?
    thks

    Yes, that is correct.  SAP is pushing the use of ABAP Objects and you can not use OCCURS or HEADER LINEs in the ABAP OO context.  You should always defined explicitly and a work area.
    Data: itab type table of mara.
    Data: wa like line of itab.
    So then you must keep this in mind when doing any operations on internal tables, like in the case of the COLLECT statement, the syntax would be.
    wa-field1 = '1'.
    wa-field2 = '2'.
    Collect wa into itab.
    Regards,
    Rich Heilman

  • Good practice for charging notebook

    Gday,
    I just bought new pavilion notebook and  read this on the User Manual: "The computer does not use battery power when the computer is connected to AC external power with an approved AC adapter or an optional docking/expansion device." (chapt 6 p36)
    I'd like to have my notebook battery as healthy and longest live as possible, my quest is do I need to unplug the power adapter when the battery indicator shows 100% when charging while using the notebook? or just leave the power adapter plugged on AC as it is indicated on the Manual.
    Many thaks,
    This question was solved.
    View Solution.

    Hi,
    All smart batteries and chargers are smarter than we thought. When unplug AC power, computer will use battery and at the end of the day battery needs more charging cycles.
    My observations (I've mentioned many times on this forums): leaving batteries and machines 24/24 on AC at the end of two years, their batteries are much better than the ones pluged/unpluged everyday.
    Hope this helps.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • What are the best practices for using the enhancement framework?

    Hello enhancement framework experts,
    Recently, my company upgraded to SAP NW 7.1 EhP6.  This presents us with the capability to use the enhancement framework.
    A couple of senior programmers were asked to deliver a guideline for use of the framework.  They published the following statement:
    "SAP does not guarantee the validity of the enhancement points in future releases/versions. As a result, any implemented enhancement points may require significant work during upgrades. So, enhancement points should essentially be used as an alternative to core modifications, which is a rare scenario.".
    I am looking for confirmation or contradiction to the statement  "SAP does not guarantee the validity of enhancement points in future releases/versions..." .  Is this a true statement for both implicit and explicit enhancement points?
    Is the impact of activated explicit and implicit enhancements much greater to an SAP upgrade than BAdi's and user exits?
    Is there any SAP published guidelines/best practices for use of the enhancement framework?
    Thank you,
    Kimberly
    Edited by: Kimberly Carmack on Aug 11, 2011 5:31 PM

    Found an article that answers this question quite well:
    [How to Get the Most From the Enhancement and Switch Framework as a Customer or Partner - Tips from the Experts|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/c0f0373e-a915-2e10-6e88-d4de0c725ab3]
    Thank you Thomas Weiss!

  • Best practice for tracking database changes...?

    Dear Oracle gurus,
    I'm still relatively new to database administrating, and recently I ran into a situation which I'm not sure if there's some text-book scenario analysis or practice.
    I find it hard to track all the database changes across different servers. Our company develop software that uses the Oracle database, so we have development and test servers set up here and there, with really minimal control on them. Problem arises when we make rapid design changes to our system, which required multiple and rapid changes to the databases. I find it really hard to keep track of everything, because sometimes I can't patch some server because of people still using it for development/testing/investigation/etc.
    So, is there some kind of good practices for tracking database changes (which we even write patches for), monitoring schema modifications, or maybe even versioning database objects? I've tried to find some information but I think I did not look in the right places or ask the right questions.
    Any help is appreciated.
    Best regards,
    Peter Tung

    The first thing I would start with is:
    Find a version control system that will allow you to store files and version them (PVCS for example). You could for example, store all the sql scripts. Whenever a change is needed, the user could check the program out from the version control tool and make changes and check it back in. Besides sql scripts, you could also store binary files or any type of source code files in a version control system. This would at least put some things in order. In a version control system, you could associate a number or a string with all the files within a patch.

  • Entity Framework doesn't create the database in SQL Server Management 2012, instead it just creates in (localdb)\v11.0 How to fix it?

    Hi, I'm Begginer in Entity Framework. Then I'm having some problems.
    I created my entities and I give Save Changes. (Ok)
    Then, I Tried to Connect with the database through Server Explorer, if I use the instance of the SQL Server Management Studio 2012(PC-PAULO\INSTANCIAPJ) as Server Name, the database doesn't appears but, if I use the the instance (localdb)\v11.0 the dabase
    appears.
    How to change the save to the SQL Server Management Studio 2012, I don't know where this (localDB)\v11.0 saves.
    Help-me Thank you :D

    Hello PauloJos,
    The code should be ok and it is really strange that the database is only created into the local database in your machine. I am wondering if it is related with the machine environment, could you please have a try with below demo on your machine which works
    on my side and if it is possible, please have a try to run your application on other machines to see if it works:
    class Program
    static void Main(string[] args)
    #region https://social.msdn.microsoft.com/Forums/en-US/00eff3c4-2336-4807-9212-e6f2a6c8812e/entity-framework-doesnt-create-the-database-in-sql-server-management-2012-instead-it-just-creates?forum=adodotnetentityframework
    using (CFDbContext db = new CFDbContext())
    db.Database.CreateIfNotExists();
    #endregion
    public class CFDbContext : DbContext
    public CFDbContext() : base("UltraFoda3") { }
    public DbSet<TestOne> TestOnes { get; set; }
    public class TestOne
    public int ID { get; set; }
    public string Name { get; set; }
    Config file is similar:
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </configSections>
    <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
    <parameters>
    <parameter value="v11.0" />
    </parameters>
    </defaultConnectionFactory>
    <providers>
    <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
    </entityFramework>
    <connectionStrings>
    <add name="UltraFoda3" connectionString="Data Source=YourServer;Initial Catalog=UltraFoda3;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
    </connectionStrings>
    </configuration>
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Entity Framework - Execute Stored Procedures

    I want to execute stored procedure using entity framework.
    I am using entity framework 6.
    The stored procedure has SELECT and RETURN statement.
    How can I read the output from SELECT and RETURN statements using
    dbContext.Database.ExecuteSqlCommand or dbContext.Database.SqlQuery statement ?

    Hello Sumit Kadam,
    >> The stored procedure has SELECT and RETURN statement.
    For the select statement, Entity Framework would support natively:
    http://www.entityframeworktutorial.net/stored-procedure-in-entity-framework.aspx
    For the return statement, we could use the dbContext.Database.SqlQuery statement as below to fetch the value:
    var returnCode = new SqlParameter();
    returnCode.ParameterName = "@ReturnCode";
    returnCode.SqlDbType = SqlDbType.Int;
    returnCode.Direction = ParameterDirection.Output;
    // assign the return code to the new output parameter and pass it to the sp
    var data = db.Database.SqlQuery<Order>("exec @ReturnCode = ProGetOrder", returnCode);
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Best practice for loading config params for web services in BEA

    Hello all.
    I have deployed a web service using a java class as back end.
    I want to read in config values (like init-params for servlets in web.xml). What
    is the best practice for doing this in BEA framework? I am not sure how to use
    the web.xml file in WAR file since I do not know how the name of the underlying
    servlet.
    Any useful pointers will be very much appreciated.
    Thank you.

    It doesnt matter whether the service is invoked as part of your larger process or not, if it is performing any business critical operation then it should be secured.
    The idea of SOA / designing services is to have the services available so that it can be orchestrated as part of any other business process.
    Today you may have secured your parent services and tomorrow you could come up with a new service which may use one of the existing lower level services.
    If all the services are in one Application server you can make the configuration/development environment lot easier by securing them using the Gateway.
    Typical probelm with any gateway architecture is that the service is available without any security enforcement when accessed directly.
    You can enforce rules at your network layer to allow access to the App server only from Gateway.
    When you have the liberty to use OWSM or any other WS-Security products, i would stay away from any extensions. Two things to consider
    The next BPEL developer in your project may not be aware of Security extensions
    Centralizing Security enforcement will make your development and security operations as loosely coupled and addresses scalability.
    Thanks
    Ram

  • Best practice for creating DVD

    I am trying to create a DVD of the movie i just made.
    I am wondering about the exporting feature of iMovie, beucase i want to change the frame rate from 29 fps to 25 fps to give it a more movie like feel, rather then so life like....
    is is possible? What perhaps is good practice for this?
    thanks.

    29/25 fps are Apple's latest "acronyms" for NTSC/PAL...
    you change a lot more then just framerate...
    in case you like to play the resulting DVD on a NTSC player: don't do so...
    making a more "filmish" look, deinterlace your project, using
    JES Deinterlacer (free)
    .. gives much better effect...
    finally: use the cinematize effect in iM.. adding black borders give most viewers a nice ... ehm, cinema effect.

  • BAPI or FM to get material goods issue for a prod order

    Hi
    I need a FM to get the material goods issue for a prod order. Please let me know.
    Thanks and regards
    Harish

    Hi Harish,
    use FM <b>BAPI_GOODSMVT_CREATE.</b>
    have a look at this thread ..
    FM for good issue for production order
    Regards,
    Santosh

  • Best practices for package directory structure?

    I've only compiled a few java programs & while I find the language itself very easy to adapt to from C++ and Javascript, I get confused about the directory structure and classpaths & such.
    My main method of operation is to build small tools and test projects, and I would like to follow good practices for organizing my directory structure, so it will (a) work well with java, and (b) work well with my source control software.
    Let's say I am developing packages named "com.example.test.test1", "com.example.test.test2", "com.example.tools.flapper", and "com.example.tools.spinner".
    I know I can use this structure:
    /java/test/test1/com/example/test/test1/* (files for com.example.test.test1 including test1.java)
    /java/test/test2/com/example/test/test2/* (files for com.example.test.test2 including test2.java)
    /java/tools/flapper/com/example/tools/flapper/* (files for com.example.tools.flapper including flapper.java)
    /java/tools/spinner/com/example/tools/spinner/* (files for com.example.tools.spinner including spinner.java)
    But the directories seem unnecessarily deep & lead to a hassle in source control that makes it difficult to browse.
    Can I use this? and if so, how do I run "javac" and "jar" properly to compile/jar-ify each package?
    /java/com/example/test/test1/* (files for com.example.test.test1)
    /java/com/example/test/test2/* (files for com.example.test.test2)
    /java/com/example/tools/flapper/* (files for com.example.tools.flapper)
    /java/com/example/tools/spinner/* (files for com.example.tools.spinner)
    also is it recommended to leave the .class files in the same dirs as the .java files, or better to have a separate tree for compiled .class files?

    hmm, there's a lot to absorb here...
    I found these articles online that seem good:
    http://www.onjava.com/pub/a/onjava/2003/12/17/ant_bestpractices.html
    http://www.kevinboone.com/classpath.html
    I'd like to use ant if possible & understand it; I've had troubles with IDEs in the past and would like to just stick with basic build mechanisms.
    I guess as a practical example let's say I have two different applications that use the serial port, that I want to release separately, each in separate .jar files. One is called com.example.applications.serial1 and the other is com.example.applications.serial2. They both use rxtx.org's gnu.io.* libraries. Serial1 uses some packages that I have developed: com.example.tools.spinner and com.example.tools.flapper, whereas Serial2 uses com.example.tools.spinner and com.example.tools.flopper
    I think I want to organize things this way: (everything below under /java/src/)
    com
    example
    applications
    serial1
    serial1.java
    serial2
    serial2.java
    tools
    spinner
    spinner.java
    flapper
    flapper.java
    flopper
    flopper.java
    and I think I want to compile to /java/classes/:
    com
    example
    applications
    serial1
    serial1.class
    serial2
    serial2.class
    tools
    spinner
    spinner.class
    flapper
    flapper.class
    flopper
    flopper.class
    but I'm sort of lost on where to put the ant buildfiles, which directories to be in to run javac, and how to get the jar files right. From what I've searched for online, the external libraries (RXTX's jar files & .dlls for windows) are "interesting", and the easiest thing is to tell users of my .jar files to put the rxtx libs in the same library as the .jar files so I can set the Class-Path: in the .jar manifest to point to them.

Maybe you are looking for

  • Hard drive keeps cloning itself in finder

    This is the second time I saw this on a Mac, and never happened to me before (being working in a AASP for the last 9 years) The disc fails, and won't boot, but you can see all the data starting up in Target or mounting the HD as an external device in

  • My Macbook pro keeps crashing and I have no idea why. Would anyone be able to help?

    I have a Macbook pro OS X 10.7.5 It is only a little over a year old and it keeps crashing. Any help would be great! Process:         crsud [47] Path:            /usr/libexec/crsud Identifier:      crsud Version:         ??? (???) Code Type:       X8

  • Displaying data in different tabs

    Hi all In a webI report I want to display data in different tabs for different prompt values. For ex: In the prompt window if enter one value for plant say ABC... data should display in a single tab If I enter two values say ABC, DEF... data should d

  • Documentation on weblogic patch 10.3.6.0.7

    Hi, Oracle released new patch for weblogic server 10.3.6 last week. I couldn't find any documentation on the new patch(details like new features or fixes) online. If you have any details, please share. Regards, Ram

  • Captivate 6 crashes at startup

    I have installed Captivate 6 (Demo) on my Mac (Retina MBP with MacOS X 10.8.2). Whenever I try to create a new project at startup, the app crashes with the following message (in german, sorry) "Schwerwiegender Fehler. Die Anwendung wird beendet. Adob