Click here to Skip to main content
15,886,362 members
Home / Discussions / C#
   

C#

 
Generalconverting xsl:fo Or XML DOCUMENT to pdf using c sharp Pin
Asim N.28-Oct-02 1:24
Asim N.28-Oct-02 1:24 
Generalconverting xsl:fo to pdf using c sharp Pin
Asim N.28-Oct-02 1:22
Asim N.28-Oct-02 1:22 
GeneralRe: MIcrosoft.data.odbc and sybase Pin
Richard Deeming28-Oct-02 1:26
mveRichard Deeming28-Oct-02 1:26 
QuestionHow to subclass a Window Pin
Member 4337827-Oct-02 22:31
Member 4337827-Oct-02 22:31 
AnswerRe: How to subclass a Window Pin
Stephane Rodriguez.27-Oct-02 23:54
Stephane Rodriguez.27-Oct-02 23:54 
GeneralC#+VS.NET: my proxy is using the wrong library Pin
brotkopp27-Oct-02 5:40
brotkopp27-Oct-02 5:40 
GeneralRe: C#+VS.NET: my proxy is using the wrong library Pin
Stephane Rodriguez.27-Oct-02 7:09
Stephane Rodriguez.27-Oct-02 7:09 
GeneralRe: C#+VS.NET: my proxy is using the wrong library Pin
brotkopp27-Oct-02 8:34
brotkopp27-Oct-02 8:34 
here you are, this is the library:

<br />
using System;<br />
<br />
namespace ChatLib<br />
{<br />
	/// <summary><br />
	/// Zusammendfassende Beschreibung für Class1.<br />
	/// </summary><br />
	public class ChatMsg<br />
	{<br />
		public string content;<br />
		public long authorid;<br />
		public long messageid;<br />
<br />
		public ChatMsg()<br />
		{<br />
			this.content = "";<br />
			this.messageid = 0;<br />
			this.authorid = 0;<br />
		}<br />
			public ChatMsg(string msg)<br />
		{<br />
			this.content = msg;<br />
			this.messageid = 0;<br />
			this.authorid = 0;<br />
		}<br />
			public ChatMsg(string msg, long number)<br />
		{<br />
			this.content = msg;<br />
			this.messageid = number;<br />
			this.authorid = 0;<br />
		}<br />
			public ChatMsg(string msg, long number, long id)<br />
		{<br />
			this.content = msg;<br />
			this.messageid = number;<br />
			this.authorid = id;<br />
		}<br />
	}<br />
<br />
}


this is the webservice:

<br />
using System;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Diagnostics;<br />
using System.Web;<br />
using System.Web.Services;<br />
using ChatLib;<br />
<br />
<br />
namespace chatserver02<br />
{<br />
	/// <summary><br />
	/// Zusammendfassende Beschreibung für Service1.<br />
	/// </summary><br />
	public class Service1 : System.Web.Services.WebService<br />
	{<br />
		//private static string currentmsg = "";<br />
		//private int progressid = 0;<br />
		<br />
		private const int buffersize = 5;<br />
		private static ChatMsg[] msgbuffer = new ChatMsg[buffersize];<br />
		private static long lastid = 0;<br />
		private static int lastpos = 0;<br />
<br />
		private ChatMsg MsgNum(int pos)<br />
		{<br />
			if(pos >= buffersize)<br />
			{<br />
				ChatMsg nullmsg = new ChatMsg("", -1);<br />
				return nullmsg;<br />
			}<br />
			int realpos = 0;<br />
            realpos = (lastpos - pos)%buffersize;<br />
			return msgbuffer[realpos];<br />
		}<br />
<br />
		public Service1()<br />
		{<br />
			//CODEGEN: Dieser Aufruf ist für den ASP.NET-Webdienst-Designer erforderlich.<br />
			InitializeComponent();<br />
		}<br />
<br />
		#region Component Designer generated code<br />
		<br />
		//Erforderlich für den Webdienst-Designer <br />
		private IContainer components = null;<br />
				<br />
		/// <summary><br />
		/// Erforderliche Methode für die Designerunterstützung. <br />
		/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.<br />
		/// </summary><br />
		private void InitializeComponent()<br />
		{<br />
		}<br />
<br />
		/// <summary><br />
		/// Die verwendeten Ressourcen bereinigen.<br />
		/// </summary><br />
		protected override void Dispose( bool disposing )<br />
		{<br />
			if(disposing && components != null)<br />
			{<br />
				components.Dispose();<br />
			}<br />
			base.Dispose(disposing);		<br />
		}<br />
		<br />
		#endregion<br />
<br />
		// WEBDIENSTBEISPIEL<br />
		// Der HelloWorld()-Beispieldienst gibt die Zeichenfolge Hello World zurück.<br />
		// Entfernen Sie den Kommentar in folgenden Zeilen. Speichern und erstellen Sie anschließend das Projekt.<br />
		// Drücken Sie F5, um den Webdienst zu testen.<br />
<br />
		[WebMethod]<br />
		public ChatMsg Horch(long lastmsg)<br />
		{<br />
			/*if(lastmsg != currentmsg)<br />
			{<br />
				return currentmsg;<br />
			}<br />
			else<br />
			{<br />
			return "";<br />
			}*/<br />
<br />
			/*return currentmsg;<br />
<br />
			/*if (currentmsg == "")<br />
				return "!";<br />
			else*/<br />
			if(lastmsg < (lastid - buffersize))<br />
			{<br />
				lastmsg = lastid - buffersize;<br />
			}<br />
<br />
			ChatMsg returnmsg = new ChatMsg("", lastid);<br />
<br />
			if(lastmsg < lastid)<br />
			{<br />
				while(lastmsg < lastid)<br />
				{<br />
					returnmsg.content = returnmsg.content + MsgNum((int)lastid - (int)lastmsg).content;<br />
					lastmsg ++;<br />
				}<br />
				return returnmsg;<br />
			}<br />
			else<br />
			{<br />
				return new ChatMsg("", lastid);<br />
			} <br />
		}<br />
<br />
		[WebMethod]<br />
		public int Verkuend(string text)<br />
		{<br />
			lastid = lastid + 1;<br />
			ChatMsg newmsg = new ChatMsg(text, lastid);<br />
			newmsg.content = newmsg.content + "\n\n";<br />
			lastpos = (lastpos + 1)%buffersize;<br />
			msgbuffer[lastpos] = newmsg;<br />
			return 0;<br />
		}<br />
	}<br />
}<br />


and this is the client:

<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
using ChatLib;<br />
//using chatclient02.localhost;<br />
<br />
namespace chatclient02<br />
{<br />
	/// <summary><br />
	/// Zusammendfassende Beschreibung für Form1.<br />
	/// </summary><br />
	public class Form1 : System.Windows.Forms.Form<br />
	{<br />
		public static Form1 me;<br />
		<br />
		private long mylastmsg = 0;<br />
<br />
		private System.Windows.Forms.TextBox inbox;<br />
		private System.Windows.Forms.Button sendbutton;<br />
		private System.Windows.Forms.TextBox outbox;<br />
		private System.Windows.Forms.Button startbutton;<br />
		private System.Windows.Forms.StatusBar feedbackbar;<br />
		/// <summary><br />
		/// Erforderliche Designervariable.<br />
		/// </summary><br />
		private System.ComponentModel.Container components = null;<br />
<br />
		public Form1()<br />
		{<br />
			//<br />
			// Erforderlich für die Windows Form-Designerunterstützung<br />
			//<br />
			InitializeComponent();<br />
<br />
			//<br />
			// TODO: Fügen Sie den Konstruktorcode nach dem Aufruf von InitializeComponent hinzu<br />
			//<br />
		}<br />
<br />
		/// <summary><br />
		/// Die verwendeten Ressourcen bereinigen.<br />
		/// </summary><br />
		protected override void Dispose( bool disposing )<br />
		{<br />
			if( disposing )<br />
			{<br />
				if (components != null) <br />
				{<br />
					components.Dispose();<br />
				}<br />
			}<br />
			base.Dispose( disposing );<br />
		}<br />
<br />
		private void sendbutton_Click(object sender, System.EventArgs e)<br />
		{<br />
			localhost.Service1 pf = new localhost.Service1();<br />
<br />
			//Instantiate an AsyncCallback delegate to use as a parameter<br />
			//in the BeginFactorize method.<br />
			AsyncCallback cb = new AsyncCallback(Form1.donothing);<br />
<br />
			// Begin the Async call to Factorize, passing in our<br />
			// AsyncCalback delegate and a reference<br />
			// to our instance of PrimeFactorizer.<br />
			IAsyncResult ar = pf.BeginVerkuend(inbox.Text, cb, pf);<br />
			<br />
			/*int elli = 0;<br />
			localhost.Service1 pf = new localhost.Service1();<br />
			elli = pf.Verkuend(inbox.Text);<br />
			inbox.Text = elli.ToString();*/<br />
<br />
			//inbox.Text = ar.ToString();<br />
			//outbox.AppendText(inbox.Text);<br />
<br />
			inbox.Text = "";<br />
			inbox.Focus();<br />
<br />
			feedbackbar.Text = "sende botschaft...";<br />
		}<br />
<br />
		public static void donothing(IAsyncResult ar)<br />
		{<br />
			localhost.Service1 pf = (localhost.Service1) ar.AsyncState;<br />
			//me.outbox.Text = pf.EndVerkuend(ar);<br />
			me.feedbackbar.Text = "botschaft gesendet";<br />
		}<br />
<br />
		#region Windows Form Designer generated code<br />
		/// <summary><br />
		/// Erforderliche Methode für die Designerunterstützung. <br />
		/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.<br />
		/// </summary><br />
		private void InitializeComponent()<br />
		{<br />
			this.inbox = new System.Windows.Forms.TextBox();<br />
			this.sendbutton = new System.Windows.Forms.Button();<br />
			this.outbox = new System.Windows.Forms.TextBox();<br />
			this.startbutton = new System.Windows.Forms.Button();<br />
			this.feedbackbar = new System.Windows.Forms.StatusBar();<br />
			this.SuspendLayout();<br />
			// <br />
			// inbox<br />
			// <br />
			this.inbox.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) <br />
				| System.Windows.Forms.AnchorStyles.Right);<br />
			this.inbox.Location = new System.Drawing.Point(0, 152);<br />
			this.inbox.Multiline = true;<br />
			this.inbox.Name = "inbox";<br />
			this.inbox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;<br />
			this.inbox.Size = new System.Drawing.Size(288, 48);<br />
			this.inbox.TabIndex = 0;<br />
			this.inbox.Text = "";<br />
			// <br />
			// sendbutton<br />
			// <br />
			this.sendbutton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);<br />
			this.sendbutton.Location = new System.Drawing.Point(144, 200);<br />
			this.sendbutton.Name = "sendbutton";<br />
			this.sendbutton.Size = new System.Drawing.Size(144, 32);<br />
			this.sendbutton.TabIndex = 1;<br />
			this.sendbutton.Text = "send";<br />
			this.sendbutton.Click += new System.EventHandler(this.sendbutton_Click);<br />
			// <br />
			// outbox<br />
			// <br />
			this.outbox.AcceptsReturn = true;<br />
			this.outbox.AllowDrop = true;<br />
			this.outbox.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) <br />
				| System.Windows.Forms.AnchorStyles.Left) <br />
				| System.Windows.Forms.AnchorStyles.Right);<br />
			this.outbox.BackColor = System.Drawing.SystemColors.Window;<br />
			this.outbox.Multiline = true;<br />
			this.outbox.Name = "outbox";<br />
			this.outbox.ReadOnly = true;<br />
			this.outbox.RightToLeft = System.Windows.Forms.RightToLeft.No;<br />
			this.outbox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;<br />
			this.outbox.Size = new System.Drawing.Size(288, 152);<br />
			this.outbox.TabIndex = 2;<br />
			this.outbox.Text = "";<br />
			// <br />
			// startbutton<br />
			// <br />
			this.startbutton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);<br />
			this.startbutton.Location = new System.Drawing.Point(0, 200);<br />
			this.startbutton.Name = "startbutton";<br />
			this.startbutton.Size = new System.Drawing.Size(144, 32);<br />
			this.startbutton.TabIndex = 3;<br />
			this.startbutton.Text = "start session";<br />
			this.startbutton.Click += new System.EventHandler(this.startbutton_Click);<br />
			// <br />
			// feedbackbar<br />
			// <br />
			this.feedbackbar.Location = new System.Drawing.Point(0, 238);<br />
			this.feedbackbar.Name = "feedbackbar";<br />
			this.feedbackbar.Size = new System.Drawing.Size(288, 16);<br />
			this.feedbackbar.TabIndex = 4;<br />
			this.feedbackbar.Text = "...";<br />
			// <br />
			// Form1<br />
			// <br />
			this.AcceptButton = this.sendbutton;<br />
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
			this.ClientSize = new System.Drawing.Size(288, 254);<br />
			this.Controls.AddRange(new System.Windows.Forms.Control[] {<br />
																		  this.feedbackbar,<br />
																		  this.startbutton,<br />
																		  this.outbox,<br />
																		  this.sendbutton,<br />
																		  this.inbox});<br />
			this.MinimizeBox = false;<br />
			this.Name = "Form1";<br />
			this.Text = "Form1";<br />
			this.ResumeLayout(false);<br />
<br />
		}<br />
		#endregion<br />
<br />
		/// <summary><br />
		/// Der Haupteinstiegspunkt für die Anwendung.<br />
		/// </summary><br />
		[STAThread]<br />
		static void Main() <br />
		{<br />
			me = new Form1();<br />
			Application.Run(me);<br />
		}<br />
<br />
		private void startbutton_Click(object sender, System.EventArgs e)<br />
		{<br />
			localhost.Service1 pf = new localhost.Service1();<br />
<br />
			//Instantiate an AsyncCallback delegate to use as a parameter<br />
			//in the BeginFactorize method.<br />
			AsyncCallback cb = new AsyncCallback(Form1.incomming);<br />
<br />
			// Begin the Async call to Factorize, passing in our<br />
			// AsyncCalback delegate and a reference<br />
			// to our instance of PrimeFactorizer.<br />
			IAsyncResult ar = pf.BeginHorch(mylastmsg, cb, pf);<br />
<br />
			feedbackbar.Text = "erwarte daten von " + ar.ToString();<br />
		}<br />
<br />
		public static void incomming(IAsyncResult ar)<br />
		{<br />
			localhost.Service1 pf = (localhost.Service1) ar.AsyncState;<br />
			ChatMsg ergebnis = pf.EndHorch(ar);<br />
<br />
<br />
			if(me.mylastmsg != ergebnis.messageid)<br />
			{<br />
				me.feedbackbar.Text = "habe daten empfangen";<br />
				me.mylastmsg = ergebnis.messageid;<br />
				me.outbox.AppendText(ergebnis.content.Replace("\n","\r\n"));<br />
			}<br />
<br />
			me.feedbackbar.Text = "erwarte daten...";<br />
			//---- Und nochmal das ganze ----<br />
			<br />
			System.Timers.Timer aTimer = new System.Timers.Timer();<br />
			aTimer.Elapsed+= new System.Timers.ElapsedEventHandler(OnTimedEvent);<br />
			// Set the Interval to 1/4 second.<br />
			aTimer.Interval = 250;<br />
			aTimer.AutoReset = false;<br />
			aTimer.Enabled = true;<br />
		}<br />
<br />
		public static void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)<br />
		{<br />
			localhost.Service1 pf = new localhost.Service1();<br />
			//Instantiate an AsyncCallback delegate to use as a parameter<br />
			//in the BeginFactorize method.<br />
			AsyncCallback cb = new AsyncCallback(Form1.incomming);<br />
<br />
			// Begin the Async call to Factorize, passing in our<br />
			// AsyncCalback delegate and a reference<br />
			// to our instance of PrimeFactorizer.<br />
			IAsyncResult arn = pf.BeginHorch(me.mylastmsg, cb, pf);<br />
		}<br />
	}<br />
}<br />


hope this might help...

PS: the code is a bit messy i guess, parts of it are from the VS help, anyway, the compiler has its problem with this line, where i want to start the webmethod:
IAsyncResult ar = pf.BeginHorch(mylastmsg, cb, pf);<br />

GeneralRe: C#+VS.NET: my proxy is using the wrong library Pin
brotkopp31-Oct-02 9:57
brotkopp31-Oct-02 9:57 
GeneralHelp required on 5 issues - C# Pin
Fahad Khalil26-Oct-02 19:14
sussFahad Khalil26-Oct-02 19:14 
GeneralRe: Help required on 5 issues - C# Pin
David Stone26-Oct-02 19:40
sitebuilderDavid Stone26-Oct-02 19:40 
GeneralRe: Help required on 5 issues - C# Pin
Stephane Rodriguez.26-Oct-02 19:46
Stephane Rodriguez.26-Oct-02 19:46 
GeneralRe: Help required on 5 issues - C# Pin
leppie27-Oct-02 2:26
leppie27-Oct-02 2:26 
QuestionDiff. between properties and fields? Pin
Brian Olej26-Oct-02 9:46
Brian Olej26-Oct-02 9:46 
AnswerRe: Diff. between properties and fields? Pin
Daniel Turini26-Oct-02 9:58
Daniel Turini26-Oct-02 9:58 
GeneralRe: Diff. between properties and fields? Pin
Brian Olej26-Oct-02 10:02
Brian Olej26-Oct-02 10:02 
GeneralRe: Diff. between properties and fields? Pin
Anonymous26-Oct-02 10:06
Anonymous26-Oct-02 10:06 
GeneralRe: Diff. between properties and fields? Pin
Brian Olej26-Oct-02 10:26
Brian Olej26-Oct-02 10:26 
GeneralRe: Diff. between properties and fields? Pin
leppie26-Oct-02 10:14
leppie26-Oct-02 10:14 
GeneralRe: Diff. between properties and fields? Pin
Daniel Turini26-Oct-02 10:18
Daniel Turini26-Oct-02 10:18 
GeneralRe: Diff. between properties and fields? Pin
Jon Rista26-Oct-02 13:50
Jon Rista26-Oct-02 13:50 
GeneralRe: Diff. between properties and fields? Pin
Brian Olej29-Oct-02 8:45
Brian Olej29-Oct-02 8:45 
GeneralRe: Diff. between properties and fields? Pin
Brian Olej26-Oct-02 10:25
Brian Olej26-Oct-02 10:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.