473,396 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Calling RunWorkerCompletedEventArgs method from one form to another?

I have defined a method in Form1 which uses the RunWorkerCompletedEventArgs as follows

Expand|Select|Wrap|Line Numbers
  1.  public void CallFun(object sender, RunWorkerCompletedEventArgs e)
  2.         {
  3.             this.Status("Adding measurement ...");
  4.             if (!e.Cancelled)
  5.             {
  6.                 if (e.Error == null)
  7.                 {
  8.                     string[] dirs = Directory.GetDirectories(this.RootPath, "*", SearchOption.AllDirectories);
  9.                  foreach (string dir in dirs)
  10.                    {
  11.                        Console.Write(dir + "<br>");
  12.                     }
  13.                     Console.Write(dirs[17]);   
  14.                 }
  15.                 else
  16.                 {
  17.                     this.Status(string.Concat("Error: ", e.Error.Message));
  18.                     Thread.Sleep(500);
  19.                 }
  20.             }
  21.             else
  22.             {
  23.                 this.Status("Canceled!");
  24.                 Thread.Sleep(500);
  25.             }
  26.             this.Status();
  27.         }
I want to use this particular methon CallFun in different form.
Is it possible?

I tried the following in Form2

Expand|Select|Wrap|Line Numbers
  1.  Form1 form1 = new Form1();
  2. form1.CallFun(sender, e);
  3.  
This give the following 2 errors:
1) The best overloaded method match for 'X.Form1.CallFun(object, System.ComponentModel.RunWorkerCompletedEventArgs) ' has some invalid arguments

2) Ecannot convert from 'System.EventArgs' to 'System.ComponentModel.RunWorkerCompletedEventArgs '

I am clueless where I am going wrong as I m very new to C#.
Any suggestions will be greatly appreciated.
Thank you.
Jun 28 '13 #1
0 1278

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: kingofkolt | last post by:
hi all, just wondering what the syntax is for calling a method of a class from another method of that same class? for example... class Test { var $test="foo"; function printTest() {
5
by: Chris | last post by:
Hi I have a scenario where I've created another AppDomain to dynamically load a DLL(s) into. In this newly loaded DLL I want to call a static method on a class. The problem arise is that I have...
0
by: George Vodpik | last post by:
Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <e1$RDGmfEHA.2200@TK2MSFTNGP09.phx.gbl> Newsgroups: microsoft.public.dotnet.general...
2
by: Todd | last post by:
This has really been my day for wierd problems sorting one of my forms (a subform actually)... so here's another one. I am now receiving the following error Run-time error '-2146500594...
2
by: Jan | last post by:
Here's the code with the problem: class Startup { public static string Sym; public static string PrevDate; public static int Highest = new int; // ______________
33
by: Partha Protim Roy | last post by:
Hello, I have a Customer form say A to enter/update customer details. In the Form A I have a button which opens another form say B. In the Form B, I am providing user with a option to search...
6
by: Rob Cowie | last post by:
Hi all, Is there a simple way to call every method of an object from its __init__()? For example, given the following class, what would I replace the comment line in __init__() with to result...
3
by: Jayman777 | last post by:
Hello, I am using PHP 4.4.1 and am having problems retrieving an object from an array of objects and then calling a method on it. Here are two simple classes that I am using: class Day...
0
by: Rik Moed | last post by:
Hi all, I encounter a problem with a library method that should create a multi dimensional string array. Below is the method:...
1
by: svatauli1983 | last post by:
Hi all, can someone write me if is normal to have business layer of static methods. Example: from page.aspx.cs calling static method in other assembly (static methods doesnt use state variables)....
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.