I want to put this method into background worker class, i am trying but stuck, can any one help me how to run this method into background worker class:
I am calling this method into my asp.net page, where file are zipped on server and then returend to the client. but zipping of file may take longer and user will see a busy screen, so to avoid that i want to use background worker class:
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)] public string Zip(string f, bool original) { string zip = ""; try { files = HttpContext.Current.Server.UrlDecode(files); string[] fileCollection = files.Split('*'); zipFile = class1.zipfile(fileCollection, IsOriginal); int fileLength = files.Length; } catch (Exception ex) { Console.WriteLine("Exception during processing {0}", ex); } return File; }
BackgroundWorker- it should be simply a case of putting your code in place of theirs. Also, note that background worker is more commonly used to avoid blocking a UI - sure, you can use it from a console, but that is less common. In many ways, I might just useThreadPoolhere...zipis never used. And you are returningFilethat does not exist anywhere.BackgroundWorkerin a web app? Who told you to do that?