I have an application with a ListView that contains some filenames and filepaths that I want to pass to a BackgroundWorker. I essentially want the worker thread to know the strings that this ListView contains one way or another.
While tinkering with this and searching around I have tried making a public ref Class so that I can send it to the RunWorkerAsync() function, which gives me a can not convert to System::Object error:
public ref class FileInfoContainer {
public:
    cli::array<System::String^>^ filepaths;
    cli::array<System::String^>^ filenames;
    System::String^ outfile;
    FileInfoContainer(cli::array<System::String^>^ filepaths, cli::array<System::String^>^ filenames, System::String^ outfile);
};
I have also tried passing the whole Form as an argument to RunWorkerAsync() which, during debugging, indeed passes every piece of data the Form has into a System::Object. The problem is that if I try to access an element of my form through this object I get a not member of System::Object error:
private: System::Void compworker_DoWork(System::Object^  sender, System::ComponentModel::DoWorkEventArgs^  e) {
    BackgroundWorker^ worker = dynamic_cast<BackgroundWorker^>(sender);
    System::Object^ arg = e->Argument;
    arg->button1    //this fails
    MainForm form1 = (MainForm)e->Argument;  //this also fails, even though I've seen it suggested in numerous threads
}
Any good suggestions about how I can pass my arguments to the worker thread?