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

  • SEARCH
  • Home
  • 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 8930401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:53:08+00:00 2026-06-15T08:53:08+00:00

I have this: private void BtnCheckClick(object sender, EventArgs e) { var a = txtLot.Text;

  • 0

I have this:

private void BtnCheckClick(object sender, EventArgs e)
{
        var a = txtLot.Text;
        var b = cmbMcu.SelectedItem.ToString();
        var c = cmbLocn.SelectedItem.ToString();
        btnCheck.BackColor = Color.Red;
        var task = Task.Factory.StartNew(() => 
                           Dal.GetLotAvailabilityF41021(a, b, c));
        task.ContinueWith(t =>
        {
                btnCheck.BackColor = Color.Transparent;
                lblDescriptionValue.Text = t.Result.Description;
                lblItemCodeValue.Text = t.Result.Code;
                lblQuantityValue.Text = t.Result.AvailableQuantity.ToString();
        },TaskScheduler .FromCurrentSynchronizationContext() );
        LotFocus(true);
}

and i followed J. Skeet’s advice to move into async,await in my .NET 4.0 app. I converted into this:

private async void BtnCheckClick(object sender, EventArgs e)
{
        var a = txtLot.Text;
        var b = cmbMcu.SelectedItem.ToString();
        var c = cmbLocn.SelectedItem.ToString();
        btnCheck.BackColor = Color.Red;
        JDEItemLotAvailability itm = await Task.Factory.StartNew(() => Dal.GetLotAvailabilityF41021(a, b, c));
        btnCheck.BackColor = Color.Transparent;
        lblDescriptionValue.Text = itm.Description;
        lblItemCodeValue.Text = itm.Code;
        lblQuantityValue.Text = itm.AvailableQuantity.ToString();
        LotFocus(true);
}

It works fine. What confuses me is that i could do it without using Task but just the method of my Dal. But that means that i must have modified my Dal method, which is something i dont want?

I would appreciate if someone would explain to me in “plain” words if what i did is optimal or not and why.

Thanks

P.s. My dal method

public bool CheckLotExistF41021(string _lot, string _mcu, string _locn)
{
        using (OleDbConnection con = new OleDbConnection(this.conString))
        {
                OleDbCommand cmd = new OleDbCommand();
                cmd.CommandText = "select lilotn from proddta.f41021 " +
                                        "where lilotn = ? and trim(limcu) = ? and lilocn= ?";
                cmd.Parameters.AddWithValue("@lotn", _lot);
                cmd.Parameters.AddWithValue("@mcu", _mcu);
                cmd.Parameters.AddWithValue("@locn", _locn);
                cmd.Connection = con;
                con.Open();
                OleDbDataReader rdr = cmd.ExecuteReader();
                bool _retval = rdr.HasRows;
                rdr.Close();
                con.Close();
                return _retval;
        }
}
  • 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-15T08:53:08+00:00Added an answer on June 15, 2026 at 8:53 am

    No, that’s not optimal at all. If you cannot change your DAL layer to be asynchronous you are not gaining much by using async/await. You are simply running your blocking DAL method inside a seprate background thread. If you want real gain, you should modify your DAL method to use asynchronous ADO.NET, a.k.a BeginXXX and EndXXX methods. Once you do that you will get real benefit from I/O Completion Ports. No threads will ever be jeopardized during the execution of the database call.

    If you cannot modify your DAL method, whether you are using JDEItemLotAvailability itm = await Task.Factory.StartNew(() => Dal.GetLotAvailabilityF41021(a, b, c)); or manual thread creation, really, you gain nothing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have This in C# private void counter_Tick(object sender, EventArgs e) { Time.Text =
I have this code: private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e) { if (listBox1.SelectedItem !=
I have this code: private void timer1_Tick(object sender, EventArgs e) { #region BaseAddress Process[]
i have a code which is like this : private void testToolStripMenuItem_Click(object sender, EventArgs
I have this function: private void button6_Click(object sender, EventArgs e) { crawlLocaly1 = new
hello atm I have this code private void checkBox1_CheckedChanged(object sender, EventArgs e) { if
I have this method: private void listView1_DoubleClick(object sender, EventArgs e) { if (listView1.SelectedItems.Count >
i have this code: private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { this.WindowState = FormWindowState.Minimized;
I have a strange problem. I have this code: private void button1_Click(object sender, EventArgs
I have this code: private void ToLocalSiteOnlyToolStripMenuItem_Click(object sender, EventArgs e) { if (buttonSwitch ==

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.