|
Hi, I am not really sure how to implement this, but I need to do it, and it has to be performant.
What is the most performant way to access the cache from a classlibrary ?
Can you give me some links ?
I have to do it for monday and I have not a clear idea on how to make it
Anyway, thanks in advance!
PS: I don't know if it might help, but it's a class library that receives calls and sessions from a web app and has to manage them and do things with the cache.
|
|
|
|
|
Hi, everything I've read seems to tell me the following code should work.. even the MSDN example seems to suggest this. I'm new to .NET and I've been trying to get this working for several days, does anyone have any idea why this doesn't work? I'm getting "Cross-thread operation not valid: Control 'Form1' accessed from a thread other than the thread it was created on." at ' Me.Text = "TEST" '
---------------------------------------------------
Imports System.Threading
Public Class Form1
Delegate Sub TEST()
Private TESTING As TEST
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ThreadBAH As New Thread(AddressOf DoCallBack)
Me.TESTING = New TEST(AddressOf Me.TakeArgs)
ThreadBAH.Start()
End Sub
Private Sub DoCallBack()
Me.TESTING()
End Sub
Private Sub TakeArgs()
Me.Text = "TEST"
End Sub
End Class
---------------------------------------------
All help appreciated.
---
Assimilating Knowledge
|
|
|
|
|
This is quite a well known error. Just Google "Cross-thread operation not valid" and you'll see a heap of discussions and possible work arounds for this code.
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|
|
Hi All,
I need to Add an button in Reporting Service 2005 in Report Viewer control besides 'View Report' button.
How/Where can we get the source code of the Report Viewer.
How can I display a small pop up web page from Report Viewer.
Thanks in advance.
Regards,
K.C.Sekhar
Thanks in advance
|
|
|
|
|
Hi,
How do I get the coordinates of a series of points which form a shape in an image? Is there a way to do this? What image format will be easier for this task?
By the way, I need to do this in vb.net. Hope someone can help.
-- modified at 8:55 Monday 7th August, 2006
|
|
|
|
|
Are you saying that you're trying to recognize a shape in an image??
The image format really wouldn't make that much of a difference. Machine "vision" is still very much a research topic in Uni.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Yup...that's what I want to do. I need the series of x and y coordinates to drive something like an x-y plotter.
What I'm doing now is to get the color of image's pixel(1,1) and use the maketransparent method for this color so that the background will be transparent. I assumed that this will result in the onli pixels which are not transparent are the outline of the shape since I had applied canny edge detection to the image. Then, I will check each pixel, if pixel(x,y) is NOT transparent(which is supposed to be the shape) then the x and y values will be stored. But somehow, even pixel(1,1) is not transparent when I test the code. Did I made mistake somewhere?
This is my code :
Dim x As Integer
Dim y As Integer
Dim pic as Bitmap=Image.FromFile("C:\Program Files\Inkscape\staredge.bmp")
Dim xmax As Integer=pic.Width-1
Dim ymax As Integer=pic.Height-1
try
pic.MakeTransparent(pic.GetPixel(1, 1))
Catch
MsgBox("failed")
end try
Do While x <= xmax
y = 0
Do While y <= ymax
Dim c As System.Drawing.Color = pic.GetPixel(x, y)
If c = System.Drawing.Color.Transparent Then
wait2send("Untitled - Notepad", "none{ENTER}", 0)
Else
wait2send("Untitled - Notepad", "yes{ENTER}",0)
End If
y += 1
Loop
x += 1
Loop
I used the try and catch method to test whether the maketransparent method worked. The MsgBox("failed") did not appear, so it should worked. But I couldn't figure out what is the problem. Can you please advise?
|
|
|
|
|
Color.Transparent isn't what you think it is when GetPixel is used. AFAIK, GetPixel NEVER returns transparent pixels! You'd be better off finding the pixels that are closer to the color that you're looking for.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Can I ask u a question? If the image was converted to grayscale and then canny edge detection was applied to it, does that mean the final image contains only two types of colors?
|
|
|
|
|
szevy_suez wrote: does that mean the final image contains only two types of colors?
Uhhh, Light Gray and Dark Gray?? What are you talking about?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Since I want to recognise a shape in an image, I need to know what color the shape's pixels contain, so I can check each pixel's color to identify whether the pixel belongs to the shape. However, I am not sure about the exact color. Do you know how to change an image to a 2bit black and white image? That shud make that easier rite?
Currently, I was only able to change the image to grayscale image and then apply edge detection to it, to get the outline of the shape, since what I want is only the x and y coordinates of the outline. Then, since you said GetPixel don't really return transparent color, what I thought was to get the color of GetPixel(1,1) which usually belongs to the background of the image and get all the x and y coordinates of pixels which do not have the same color as Pixel(1,1). But of course this could not be done if the image consist of more than two colors. Will an image after grayscale conversion and edge detection application contain more than TWO colors?
However, if I can convert the image to a 2 bit black n white image, it would be better.
Please advise.
|
|
|
|
|
szevy_suez wrote: Will an image after grayscale conversion and edge detection application contain more than TWO colors?
Yes. It'll be made up of various shades of gray. In a photograph, upwards of 65,000 shades...
Image processing is not my field. Search the articles for "Image processing" and you'll find a great series of articles by Christian Graus on image manipulation.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello There
I have build one Window Service and Installed it on Machine A. Now I am on Machine B and want to access some function of Service Running on Machine A. how ?
|
|
|
|
|
You cannot make a service perform a function unless your service is 'listening' for input. Take a look at implementing the TCPListener object in your service - there is a good article here[^] that gives some background on using TCPListener, and socket programming in general. It's in C#, but should be pretty simple to convert.
|
|
|
|
|
hi!
i have a problem in listbox
i want to add items from textbox to listview
im using following code
but it didnt work
code
lstv.Items.Add(Me.txtStatusId.Text.ToString)
lstv.Items.Add(Me.txtStartSerial.Text.ToString)
lstv.Items.Add(Me.txtEndSerial.Text.ToString)
lstv.Items.Add(Me.txtBenefit.Text.ToString)
lstv.Items.Add(Me.txtDiscount.Text.ToString)
lstv.Items.Add(Me.txtQuantity.Text.ToString)
lstv.Items.Add(Me.txtTotalAmount.Text.ToString)
it adds data to listview in rowwise i want to add data columnwise
note: lstv is the listview and txtStatusId is textbox etc
-- modified at 7:59 Monday 7th August, 2006
khurram saddique
|
|
|
|
|
Dim lst as new listViewItem(Me.txtStatusId.Text.ToString)
lst.subitems.add(---)
lst.subitems.add(---)
lst.subitems.add(---)
lst.subitems.add(---)
lstv.items.add(lst)
|
|
|
|
|
skhurams wrote: i want to add data columnwise
Use lstv.Items.SubItems .
|
|
|
|
|
One of my pet-peves. Why are you calling .ToString() on a Text property?? Text already returns a String, so you don't need to be calling .ToString() on it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
That bugs you too?
|
|
|
|
|
I wonder if anyone could help.
How can disable or the X on a form but keep minimize button
Protected Overrides Sub OnClosed(ByVal e As System.EventArgs)
The reason is because I could have another form (child of MDI) open at the time. I want to be able to say "There is a form open cannot do this close"
Is there any code to do this or is it just a case of properties of a form.
|
|
|
|
|
on close event you get e in paramter
write
e.cancel=true ' this is stop from closing and then you can do
me.windowstate= minimize,maximized etc
or what ever
|
|
|
|
|
Not sure about removing the close button without removing the minimize button. You could use the Me.ControlBox = False property but that'll remove minimize, maximize and close.
I think a better solution would be to use the OnClosing method of the form object and set the e.Cancel = True property depending on the conditions you have set.
|
|
|
|
|
Looking at API Guide (very useful program), I found some code in VB that can help you with disabling the close button. I may post back with some udpated .NET code (I have wrote VB and VC# versions but I am at wrong computer), but as of right now this is all that I can contribute. You could also try googling the subject.
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Const MF_BYPOSITION = &H400&
Const MF_REMOVE = &H1000&
Private Sub Form_Load()
Dim hSysMenu As Long, nCnt As Long
' Get handle to our form's system menu
' (Restore, Maximize, Move, close etc.)
hSysMenu = GetSystemMenu(Me.hwnd, False)
If hSysMenu Then
' Get System menu's menu count
nCnt = GetMenuItemCount(hSysMenu)
If nCnt Then
' Menu count is based on 0 (0, 1, 2, 3...)
RemoveMenu hSysMenu, nCnt - 1, MF_BYPOSITION Or MF_REMOVE
RemoveMenu hSysMenu, nCnt - 2, MF_BYPOSITION Or MF_REMOVE ' Remove the seperator
DrawMenuBar Me.hwnd
' Force caption bar's refresh. Disabling X button
Me.Caption = "Try to close me!"
End If
End If
End Sub
|
|
|
|
|
hellow to all ..
can i load OnPaint More than one time at the same forum ?
let say i wanna load OnPaint when i click on a button ?
i am trying to do so , but i recive an error ..
help please ..
thxxx
|
|
|
|
|
What do you mean by "load OnPaint"?
What is the code that you used, and what error message do you get?
---
b { font-weight: normal; }
|
|
|
|