Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • MichalPossible 2 posts 32 karma points
    Aug 19, 2013 @ 13:36
    MichalPossible
    0

    Creating members in background thread

    I am developing a system in which user has to have a possibility to import members from csv file - but because of size of csv (it can hold over 1000 user data rows) I want to do it in background thread. Flow is following: user selects file to upload, file is uploaded to server, user does what he has to do, while new thread is being fired and rows from csv are converted to new members. The code is written and works - problem occurs, when it is moved to threaded context - Object reference not set to an instance of an object exception is being thrown when I call Member.MakeNew(email, email, email, MemberType.GetByAlias("SystemMember"), new umbraco.BusinessLogic.User(0));

    Stack trace says the problem is not in MakeNew method but in Member.GetMemberFromLoginName(email) which is called inside MakeNew. Problem does not occur when executing code from main thread.

    Please help :)

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Aug 19, 2013 @ 14:12
    Richard Soeteman
    100

    Hi,

    It's because there is no HTTPContext available on the other thread. Not the answer you are looking for. But maybe CMSImport can help. Then you can allow the user to upload the file and schedule the import process to import the file without the user have to wait for it.

    http://our.umbraco.org/projects/developer-tools/cmsimport/

    Cheers,

    Richard

  • MichalPossible 2 posts 32 karma points
    Aug 20, 2013 @ 08:59
    MichalPossible
    0

    Thank you :-) passing HttpContext solved the problem :)

Please Sign in or register to post replies

Write your reply to:

Draft