Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8854113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:48:40+00:00 2026-06-14T13:48:40+00:00

i know i could search proccessId / name of running tasks and kill processes

  • 0

i know i could search proccessId / name of running tasks and kill processes i need .

though till now i was not developing schedualed tasks / self executble Applications,

so i didn’t need to know how to make the application close itself after execition

trying to close everything (including WebDriver) via Application.Exit + OR this.Close()
right after i have got what i was looking for. mission Complete .
please close … no more work for you .
but mr . Program.cs still needs somthing from Form1.
saying somthing about
Cannot access a disposed object.
Object name: ‘Form1’.

any combination of both was returning in some point an exeption error
(from program.cs ) even though mission complete . no more code was requested .(?) by me..atleast.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using System.IO;

namespace HT_R_WbBrows2
{
    public partial class Form1 : Form
    {


    public IeEnginGenerator Iengn = new IeEnginGenerator();
    public Form1()
    {
        InitializeComponent();
        //setLogView(View.Details);

        string extractededVal = Iengn.ExtractPageValue(Iengn.itrfWebEng);
        string flnm = @" the directory path to file --> \dolarRate.asp";



        File.WriteAllText(fn, extractededVal);

        this.Close();
        Application.Exit();
    }





public  class IeEnginGenerator
{

    private string directory = Environment.CurrentDirectory;///Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);


    public   IWebDriver IwebEngine;
    public List<string> ListElementsInnerHtml = new List<string>();
    public HtmlAgilityPack.HtmlDocument Dnetdoc = new HtmlAgilityPack.HtmlDocument();

    #region <<=========== setupDriver ============>>
    public  string  ExtractPageValue(IWebDriver DDriver, string url="") 
    {
        if(string.IsNullOrEmpty(url))
        url = @"http://www.boi.org.il/he/Markets/ExchangeRates/Pages/Default.aspx";
        var service = InternetExplorerDriverService.CreateDefaultService(directory);
        service.LogFile = directory + @"\seleniumlog.txt";
        service.LoggingLevel = InternetExplorerDriverLogLevel.Trace;

        var options = new InternetExplorerOptions();
        options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;

        DDriver = new InternetExplorerDriver(service, options, TimeSpan.FromSeconds(60));
        DDriver.Navigate().GoToUrl(url);

        Dnetdoc.LoadHtml(DDriver.PageSource);
        string Target = Dnetdoc.DocumentNode.SelectNodes("//table//tr")[1].ChildNodes[7].InnerText;
           //.Select(tr => tr.Elements("td").Select(td => td.InnerText).ToList())
           //.ToList();


        return  Math.Round(Convert.ToDouble(Target), 2).ToString();

        //return "";//Math.Round(Convert.ToDouble( TempTxt.Split(' ')[10]),2).ToString();

    }
    #endregion



}






}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:48:42+00:00Added an answer on June 14, 2026 at 1:48 pm

    Why use a winform application? A Console application would probably suffice for what you are doing. Once Main() ends your app will close as well. Main() never ends in a winform app because of the applications runloop.

    Edit:

    Here would be the correct way to do this. You need to register to the forms Load event and run your code there, not in the constructor. You can’t close a winform from inside a constructor.

    Edit 2: Put this code in the Form1() constructor. Somewhere after InitializeComponent();

        this.Load += (sender,args)=>{ /*do all your work here*/  
         string extractededVal = Iengn.ExtractPageValue(Iengn.itrfWebEng);
         string flnm = @" the directory path to file --> \dolarRate.asp";
         File.WriteAllText(fn, extractededVal);
         Application.Exit(); 
      };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I could just make all the Mix_Musics public, and not worry about
I know I could solve this with a header but I'd rather not have
Does anyone know how I could track what search terms people are using to
I have some code that I know could be nicer if it's done in
I know this could be done manually with some hardcoded Linq Joins. However, I
I know I could code what I'm trying to achieve, but I'd like to
I know I could use PHP to do this, but wanted to find out
May I know how could I pass the value of driver from code behind
May i know how could i edit the style of description of the images
I don't know what could be causing this issue, but for some reason, elements

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.