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.
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.
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 :)
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
Thank you :-) passing HttpContext solved the problem :)
is working on a reply...