我想将文件分享给社交媒体。我已经获取文件列表并将其设置为应用程序对象属性,当form_Load执行时,文件列表值在applicationobject中。我在form_load中调用了backgroungworker在dowork中我要求使用从另一个类调用的方法执行某些操作。当dowork执行时,iam在应用程序对象中没有值。
这是我的代码
private CloudBuddyApp applicationObject;
public CloudBuddyApp ApplicationObject
{
get { return applicationObject; }
set { applicationObject = value; }
}
enum ProcessType
{
PublicAcess
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
processtype = ProcessType.PublicAcess;
uxbackgroundWorker.RunWorkerAsync();
}
catch (Exception error)
{
CloudBuddyLog.WriteErrorInfo("Share.cs :: Form1_Load :" + error.Message);
}
}
private void uxbackgroundWorker_DoWork(object sender, DoWorkEventArgs e)/// when it executes the count becomes zero in application
{
//try
//{
switch (processtype)
{
case ProcessType.PublicAcess:
presenter.GetPublicURL();
break;
}
//}
//catch(Exception error)
//{
// CloudBuddyLog.WriteErrorInfo("Share.cs :: uxbackgroundWorker_DoWork:" + error.Message);
//}
}
private void uxbackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
try
{
switch (processtype)
{
case ProcessType.PublicAcess:
presenter.setdata();
uxCommentTextBox.Text = generatedurl;
break;
}
}
catch (Exception error)
{
CloudBuddyLog.WriteErrorInfo("Share.cs :: uxbackgroundWorker_RunWorkerCompleted:" + error.Message);
}
}