|
Anthony_Yio wrote:
your help doesn't seem helping
Ok. One solution could be use module level variable for storing the parameter and manipulate it from with in the function.
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
|
|
|
|
|
Ok, thank you for this time although I had found some solutions in the web already.
I thought you were just one of those irresponsible people where they like to post and run. Apparently, I am glad you are not because you are trying
Some of the solutions I found was
Thread local storage
or
Save it into the object state.
|
|
|
|
|
Thanks, i forgot to point to this article.
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
|
|
|
|
|
Why can't you pass the reference to ArrayList in the constructor for ClassA()?
Gaulles
|
|
|
|
|
Reason is that I will need to process the reference parameter in the contructor itself unless I would to store the refence to a pointer but it would make my program to be unsafe.
I guess this is not an old C++ style programming anymore.
|
|
|
|
|
You could also and is probably better than spawning a new thread is to use the BeginInvoke(string str, AsyncCallback asc, object stateobject). You then call the EndInvoke(IAsyncResult result) to retrieve the answer from the function. You pass a reference to the Arraylist in the stateobject and your AsyncCallback method handles and the parameter within it's function.
The good thing here is that you don't have to create a new thread, but rather the delagate function is executing on a thread from the thread pool - no creation is necessary.
I understand that this is probably hard to understand if you've never seen it before but you can look up BeginInvoke. .NET supports asynchronous method calls wonderfully with delagate.BeginInvoke.
|
|
|
|
|
Thank you for your suggestion. I will look into it.
Actually, I just want to make a simple thread call with parameter but it ends up in complexities. Gosh, sometimes I just hate new technologies.
|
|
|
|
|
Actually it is already simple. Take a look ...
public delegate int StringDelegate(string str);
.
.
.
private int GetLength(string str)
{
return str.Length;
}
.
.
.
StringDelegate d = new StringDelegate(GetLength);
IAsyncResult ar;
ar = d.BeginInvoke("Hello", null, null);
ar.AsyncWaitHandle.WaitOne(); // Wait for the function to finish
int length = d.EndInvoke(ar); // Voila, the result
// Note that you can also have a callback function defined in the
// second parameter. If defined, this function will be called once
// the delagate has completed. In addition, you can pass a state
// object to your GetLength method like so ...
// private int GetLength(string str, object state) ...
// You now have other information in addition to the passed "Hello"
// parameter.
// Clearly delagates are the way to go. They are simple and are
// extremely flexible. Also remember that the thread runs within the
// thread pool. No creation is required !
|
|
|
|
|
Hi,
I have some postings in a database and these postings are all noted in HTML-form because my initial idea was to show them from a web-application. Now I also want to show them through a windows application, the question is: how?
So I want to render HTML and show it in a .NET Windows Application. But I can't find a control to show the HTML. I know there is a control to show Richt Text Format, but that's still no HTML. I also know you can use the Internet Explorer ActiveX component, but I don't really want to, because that component can only show HTML from physical files and URL's, not directly from a String....
Does anybody know about the existence of a .NET-component that can show HTML directly from a string or do I really have to use the IE-component???
Structured programming vs. chaotic mind boggling
|
|
|
|
|
D.D. de Kerf wrote:
Does anybody know about the existence of a .NET-component that can show HTML directly from a string or do I really have to use the IE-component???
There is no UI Windows Forms components related to HTML rendering.
With enough spare time ahead, you may write a simple HTML renderer from scratch (and post it ).
D.D. de Kerf wrote:
I really have to use the IE-component
What's wrong with it? Drag&drop the web component into your Form, then Navigate the about:blank page, and then retrieve the mshtml (microsoft.mshtml.dll primary interop assembly) object model, get the IHTMLDocument2 interface, and create an HTML rendering from a string using the IHTMLDocument2.write(...) method call. This article[^] uses mshtml.
|
|
|
|
|
Well, I didn't ever know that I could use this write-function. It is also the first time I've ever got it working. Here are the steps:
1) Add Explorer to your toolbox (customize toolbox -> COM components -> Microsoft Web Browser) and add it to your form
2) Add a reference in your C# project to Microsoft.mshtml
3) use mshtml in your .cs-file like this:
using mshtml;
4) Browse to about:blank like this (ieBrowser is the browser-component):
object o = new object();<br />
ieBrowser.Navigate("about:blank", ref o, ref o, ref o, ref o);
5) Fill the HTML from a string like this:
IHTMLDocument2 doc;<br />
object oDoc = ieBrowser.Document;<br />
doc = (IHTMLDocument2)oDoc;<br />
<br />
doc.write("<HTML>This is bold and this is italic</HTML>");
That should do the trick.
Thanks for the tips!!!
Structured programming vs. chaotic mind boggling
|
|
|
|
|
Hi , we have a free but limited control that _might_ do what you want.
http://www.compona.com/WikiEngine/WikiPageViewer.ascx?ID=44[^]
it has its own rendering engine and can render with different font settings and images.
but as i said , it is limited , no tables , no stylesheets , no selections(!) etc.
basiclly the following tags are implemented
<a href=...
<font face=... size=... color=...(named colors only right now)
<br>
<hr>
<img src="file://... or src="1" (refering to an image in an attached imagelist)
<b>
<i>
<u>
it wordwraps and can also autosize to make the content fit.
//Roger - Compona
|
|
|
|
|
I am trying to authenticate and changing password for a windows domain user using ADSI and C#. When i try to connect to the server using LDAP provider i am getting COMException and message saying Server not opperational.
Below is my code
try
{
DirectoryEntry myDirectoryEntry;
myDirectoryEntry = new DirectoryEntry
("LDAP://domain or machine name","user id","pwd");
myDirectoryEntry.Invoke("setPassword","NewPassword");
myDirectoryEntry.CommitChanges();
}
catch(System.Runtime.InteropServices.COMException ex)
{
Console.WriteLine(ex.Message);
Console.Read();
}
where i am going wrong.
your pointers in this regard appreciated
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
|
|
|
|
|
Hi,I have the seam problem but one gay told me that I should see "Profesional C#" book.You can find it in www.wrox.com.Youo can see my problem at "Active Directory - Users or whatever".
Have a nice day.
|
|
|
|
|
vg_sarev wrote:
Active Directory - Users or whatever".
I did see that post. But even those examples are giving the same *king exception "Server is not operational"
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
|
|
|
|
|
In C# is there a way to implement Thread que which is equalant to CWinThread
so that I can post messages to the Thread queue and handle message parsing
inside the Thread and post back to Main Window?
|
|
|
|
|
Code below implement such thread
<br />
[DllImport("user32.dll", CharSet=CharSet.Auto)]<br />
public static extern IntPtr PostThreadMessage( uint idThread, int msg, int wParam, int lParam);<br />
[DllImport("kernel32.dll", ExactSpelling=true, CharSet=CharSet.Auto)]<br />
public static extern int GetCurrentThreadId();<br />
[DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
public static extern bool PeekMessage(ref MSG msg, int hWnd, uint wFilterMin, uint wFilterMax, uint wFlag);<br />
[DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
public static extern bool GetMessage(ref MSG msg, int hWnd, uint wFilterMin, uint wFilterMax);<br />
[DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
public static extern bool TranslateMessage(ref MSG msg);<br />
[DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
public static extern bool DispatchMessage(ref MSG msg);<br />
<br />
#region MSG<br />
[StructLayout(LayoutKind.Sequential)]<br />
public struct MSG <br />
{<br />
public IntPtr hwnd;<br />
public int message;<br />
public IntPtr wParam;<br />
public IntPtr lParam;<br />
public int time;<br />
public int pt_x;<br />
public int pt_y;<br />
}<br />
#endregion<br />
<br />
<br />
public void AsyncShow()<br />
{<br />
if( m_guiThread == null )<br />
{<br />
ThreadStart start = new ThreadStart( BackgroundGUIThread );<br />
m_guiThread = new Thread( start );<br />
m_guiThread.IsBackground = true;<br />
m_guiThread.Start();<br />
}<br />
}<br />
<br />
public void Finish()<br />
{<br />
try<br />
{<br />
lock(this)<br />
{<br />
if( m_idThread >= 0 )<br />
{<br />
WindowsAPI.PostThreadMessage( (uint)m_idThread, (int)Msg.WM_CLOSE, 0, 0 );<br />
}<br />
<br />
m_guiThread.Abort(); <br />
m_guiThread.Join();<br />
}<br />
}<br />
catch( Exception exc )<br />
{ <br />
Trace.WriteLine( exc.Message + "\r\n" + exc.StackTrace, "PrgDlg Exception" );<br />
}<br />
}<br />
private void BackgroundGUIThread()<br />
{<br />
Thread.CurrentThread.Name = "Background GUI MsgLoop Thread";<br />
<br />
try<br />
{<br />
lock( this )<br />
{<br />
m_idThread = WindowsAPI.GetCurrentThreadId();<br />
this.Show();<br />
}<br />
<br />
MSG msg = new MSG();<br />
<br />
while( WindowsAPI.GetMessage( ref msg, 0, 0, 0 ) )<br />
{<br />
WindowsAPI.TranslateMessage( ref msg );<br />
WindowsAPI.DispatchMessage( ref msg );<br />
<br />
if( msg.message == (int)Msg.WM_CLOSE )<br />
{<br />
Trace.WriteLine( "Close", "thread (2)" );<br />
break;<br />
}<br />
}<br />
}<br />
finally<br />
{<br />
Trace.WriteLine( "Quit thread" );<br />
}<br />
}<br />
Good Luck
Alex Kucherenko
|
|
|
|
|
Alex, Thanks a lot.
Can you give me sample code , how to Implement PostMessage and Retriveing Custom messages to this Threaded Window?
|
|
|
|
|
Did you ever get a response?
I need to port an application from C++ to C# that used CWinThread too
|
|
|
|
|
I cann't understand how I should check for user in Active Directory.Evry time when I try to check for somethink in Active Directory thete rise this kind of exeption.
try
{
DirectoryEntry entry = new DirectoryEntry("LDAP://CN=Alabala");
System.DirectoryServices.DirectorySearcher mySearcher = new
System.DirectoryServices.DirectorySearcher(entry);
mySearcher.Filter = ("objectClass=user");
foreach(System.DirectoryServices.SearchResult resEnt in
mySearcher.FindAll())
{
Console.WriteLine( resEnt.Path );
}
}
catch(System.Runtime.InteropServices.COMException ex)
{
Console.WriteLine(ex.Message);
}
|
|
|
|
|
Before you say it, yes I'm using the default DoubleBuffer Method of a control.
My problem is this. I'm writing a custom drawn 3D progress bar. I've made the control and it all works swell, i'll eventually write an article about it etc...
But it flickers really bad. Peterchen has tested it and has the same problem.
I think i've narrowed it down to the fact that I'm refreshing the whole control, wait, hear me out.
The graph is Pseudo 3D, it is made up of three 'panels' which are constructed using 7 points. these points are inter related and depend on each other to work. I've tried other methods and this worked the best in my head.
Now, if the tick step is a long interval,then the problem is solved, because its not trying to refresh itself as much and the CPU can cope.
How can I get it to draw just the updated bit of the graph. Below are links to the binaries and the source as it stands now.
http://www.nonny.com/CP/SetiBar.zip[^]
"If you just say porn then you get all manner of chaff and low grade stuff." - Paul Watson, Lounge 25 Mar 03 "But a fresh install - it's like having clean sheets" - C. Maunder Lounge 3 Mar '03
Jonathan 'nonny' Newman
Homepage [www.nonny.com] [^]
|
|
|
|
|
As you code is right now there isn't much you can do to stop the flicker. But if you make the control smarter then you can eliminate most of it.
The causes of flicker are pretty basic: You take a picture, erase it, then draw over it again.
If you can skip the erase step or instead just draw over it, then you can eliminate the majority of flicker in an application. That is why the "use DoubleBuffer is said often" because you do both steps.
After looking at your source you have enabled the DoubleBuffer style bit but you missed the other two that need to be set with it, AllPaintingInWmPaint and UserPaint . That may do the trick for you, because the first one tells it to skip the drawing of the background and the second one tells the framework you are doing the drawing and not the OS.
If that doesn't do it, then you'll need to add some more intelligence to your repainting by calling Invalidate and passing in a rectangle or region which contains the area of the control that has changed. This will make the only part of the control to change be the part that was updated. As an optimization you can make the OnPaint handler paint only what it needs to by inspecting the ClipRectangle property of the PaintEventArgs.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
James T. Johnson wrote:
AllPaintingInWmPaint and UserPaint
I said it before and I'll say it again here, you are a genius. OK it was simple, and I was stupid. But thank you!
"If you just say porn then you get all manner of chaff and low grade stuff." - Paul Watson, Lounge 25 Mar 03 "But a fresh install - it's like having clean sheets" - C. Maunder Lounge 3 Mar '03
Jonathan 'nonny' Newman
Homepage [www.nonny.com] [^]
|
|
|
|
|
When user press DELETE button on datagrid ,it delete the row in datagrid.I want ask user before delete and add that row again if he/she does not confirm it.Something like what happend in MSAccess when you delete a row in datagrid.
I did some research and found RowUpdating event and I can cansel deleteing row from dataset and prevent updating dataset(with UpdateStatus.SkipCurrentRow ),but datagrid does not refreshed and deleted row in datagrid does not come back again until I close application and open it again.So if I know how to refresh datagrid correctly I can solve it too.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Ignore that suggestion (message deleted, but I know you'll be notified). I thought I was in the ASP.NET forum.
Paul
We all will feed the worms and trees So don't be shy - Queens of the Stone Age, Mosquito Song
|
|
|
|