473,396 Members | 2,020 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.

Locking Up??

Hi all,

I'd really appreciate it if someone was able to help me out with a
problem I'm having with C#. I'm a complete newbie to this, so please
excuse what may appear as a stupid question. Basically, I'm trying to
write a .NET distributed app (hopefully :p) with Indigo and .NET
Framework 2.0 (C# as my language of choice). Anyway, what I have is a
client-side object library that, when requested, will create a login
form and pass it back to the client of the library. My intention is for
the user to interact with the user interface to log into the
system.This is where it all goes a little but downhill. The actual
application that uses the object library is shown below:

==============================
Note: HIC means Human Interface Client.
==============================

using System;
using System.Collections.Generic;
using System.Text;
using WorkshopLoading.Client;
using System.Windows.Forms;

namespace WorkshopLoadingHIC
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("HIC Started...");
SystemClient sysClient = new SystemClient();
Console.WriteLine("Registering client with server...");
Console.WriteLine("Creating user login screen...");
WorkshopLoading.Client.LoginPromptForm loginForm =
sysClient.GenerateLoginPrompt();
loginForm.Show();
Console.ReadLine();
}
}
}

As you can see from this code I am attempting to create an instance of
a Windows form that has a reference to the underlying client that
created it. The user of the system creates an instance of the client,
it should (when implemented) register itself with a server and then
allow the user to log-in by providing the appropriate UI.

Anyway, the code above seems to work. I create an instance of the
SystemClient (the object is called 'sysClient'). I ask it to return to
me a Windows.Forms Form of type LoginPromptForm and then I ask it to
show itself. The problem is when I call the show method the form
appears but the controls on the form (such as the buttons Login and
Cancel) appear white (as if they are not being re-drawn properly). Then
the entire Windows Form window turns white and it reads (Not
responding...) in the Window's caption. I haven't got the fogiest what
is going on and I'd really appreciate it someone was able to point out
my mistake.
Client Library Contents...

=============
SystemClient.cs
=============

using System;
using System.Collections.Generic;
using System.Text;

namespace WorkshopLoading.Client
{
public class SystemClient
{
public SystemClient()
{
Console.WriteLine("Client started...");
}

public LoginPromptForm GenerateLoginPrompt()
{
LoginPromptForm loginFormInstance;

//Generates a login prompt for the user.
Console.WriteLine("Creating login prompt...");
loginFormInstance = new LoginPromptForm();
loginFormInstance.SetSystemClient(this);
Console.WriteLine("Login prompt created and
referenced...");
Console.WriteLine("Returning login prompt to user...");
return loginFormInstance;
}
}
}

=============
LoginForm.cs
=============

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WorkshopLoading.Client
{
public partial class LoginPromptForm : Form
{
private SystemClient m_sysClient;

public LoginPromptForm()
{
InitializeComponent();
}

public void SetSystemClient(SystemClient systemClientInstance)
{
m_sysClient = systemClientInstance;
}
private void Form1_Load(object sender, EventArgs e)
{
MessageBox.Show("Contructing login form now...");
}

private void label1_Click(object sender, EventArgs e)
{

}
}
}

=================
LoginPromptForm.cs
=================

namespace WorkshopLoading.Client
{
partial class LoginPromptForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.UserNameLabel = new System.Windows.Forms.Label();
this.PasswordLabel = new System.Windows.Forms.Label();
this.CanceLoginlButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(216, 107);
this.button1.Margin = new System.Windows.Forms.Padding(3,
4, 3, 4);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(101, 35);
this.button1.TabIndex = 0;
this.button1.Text = "Login";
this.button1.UseVisualStyleBackColor = true;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(142, 19);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(175, 22);
this.textBox1.TabIndex = 1;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(145, 60);
this.textBox2.Name = "textBox2";
this.textBox2.PasswordChar = '*';
this.textBox2.Size = new System.Drawing.Size(172, 22);
this.textBox2.TabIndex = 2;
//
// UserNameLabel
//
this.UserNameLabel.AutoSize = true;
this.UserNameLabel.Location = new System.Drawing.Point(10,
23);
this.UserNameLabel.Name = "UserNameLabel";
this.UserNameLabel.Size = new System.Drawing.Size(71, 16);
this.UserNameLabel.TabIndex = 3;
this.UserNameLabel.Text = "Username:";
this.UserNameLabel.Click += new
System.EventHandler(this.label1_Click);
//
// PasswordLabel
//
this.PasswordLabel.AutoSize = true;
this.PasswordLabel.Location = new System.Drawing.Point(11,
60);
this.PasswordLabel.Name = "PasswordLabel";
this.PasswordLabel.Size = new System.Drawing.Size(69, 16);
this.PasswordLabel.TabIndex = 4;
this.PasswordLabel.Text = "Password:";
//
// CanceLoginlButton
//
this.CanceLoginlButton.Location = new
System.Drawing.Point(109, 105);
this.CanceLoginlButton.Name = "CanceLoginlButton";
this.CanceLoginlButton.Size = new System.Drawing.Size(101,
35);
this.CanceLoginlButton.TabIndex = 5;
this.CanceLoginlButton.Text = "Cancel";
this.CanceLoginlButton.UseVisualStyleBackColor = true;
//
// LoginPromptForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F,
16F);
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(329, 152);
this.Controls.Add(this.CanceLoginlButton);
this.Controls.Add(this.PasswordLabel);
this.Controls.Add(this.UserNameLabel);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Font = new System.Drawing.Font("Arial", 9.75F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((byte)(0)));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "LoginPromptForm";
this.Text = "Login";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label UserNameLabel;
private System.Windows.Forms.Label PasswordLabel;
private System.Windows.Forms.Button CanceLoginlButton;
}
}

Many thanks for sticking with my terrible english until now.

Regards,

:-)

Craig.

May 12 '06 #1
3 1409
<cr*****@hotmail.com> wrote:

<snip>
Anyway, the code above seems to work. I create an instance of the
SystemClient (the object is called 'sysClient'). I ask it to return to
me a Windows.Forms Form of type LoginPromptForm and then I ask it to
show itself. The problem is when I call the show method the form
appears but the controls on the form (such as the buttons Login and
Cancel) appear white (as if they are not being re-drawn properly). Then
the entire Windows Form window turns white and it reads (Not
responding...) in the Window's caption. I haven't got the fogiest what
is going on and I'd really appreciate it someone was able to point out
my mistake.


I believe the problem is that you don't have a message pump running.
Try using Application.Run (loginForm) instead of calling .Show.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
May 13 '06 #2
Jon,

You are a wonderful man. I thank you for taking the time to read this
message and help this poor idiot (that being myself). It solved the
issue. I take it the message pump is a loop constantly running to
accept Windows messages.

Regards.

Craig.

May 13 '06 #3
GoogleEyeJoe <cr*****@hotmail.com> wrote:
You are a wonderful man. I thank you for taking the time to read this
message and help this poor idiot (that being myself). It solved the
issue. I take it the message pump is a loop constantly running to
accept Windows messages.


Yup, that's basically it. I suspect that a Google search for "windows
message pump" would find more detailed explanations :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
May 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Michael Chermside | last post by:
Ype writes: > For the namespaces in Jython this 'Python internal thread safety' > is handled by the Java class: > > http://www.jython.org/docs/javadoc/org/python/core/PyStringMap.html > > which...
3
by: Ryan | last post by:
I have a problem with record locking / blocking within an application. The app is quite straight forward. Written in Delphi 5 using BDE to access a SQL 7 database (Win2K server). Every so often...
9
by: john smile | last post by:
Hi All, I want to lock 2 tables on 2 servers using TABLOCKX hint. These tables function as semaphores in my application. It means when the tables are locked then other users will not be able to...
16
by: Nid | last post by:
How do I do row-level locking on SQL Server? Thanks, Nid
10
by: McFly Racing | last post by:
Thread Locking In Static Methods I have the need for a Log Manger class that has static methods. Normally I would use the lock statement or a Monitor statement both of which take a...
15
by: z. f. | last post by:
Hi, i have an ASP.NET project that is using a (Class Library Project) VB.NET DLL. for some reason after running some pages on the web server, and trying to compile the Class Library DLL, it...
7
by: Shak | last post by:
Hi all, I'm trying to write a thread-safe async method to send a message of the form (type)(contents). My model is as follows: private void SendMessage(int type, string message) { //lets...
0
by: xpding | last post by:
Hello, I have a class MyEmbededList contains a generic dictionary, the value field is actually the MyEmbededList type as well. There is another class need to access and manipulate a list of...
0
by: Cindy Huyser | last post by:
I have an Access 2000 database behind a threaded Java application that that can have have concurrent access to the same table (but not the same record). The database is set up for shared access...
1
by: Paul H | last post by:
I have an Employees table with the following fields: EmployeeID SupervisorID Fred Bob Bob John Bob Mary Bill Bill I have created a self join in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.