|
I put Try..Catch block in the places where I am call thread.abort()
But this exception throws where no thry catch block.
I guess when I am intialize the thread at the start of the mdi form such as :
Public Class frmMDIMain
Public TimerShowSplash As New Threading.Thread(AddressOf frmMDIMain.LoadPlashScreen)
Private Sub frmMDIMain_FormClosing(ByVal sender As Object, ByVal e As ..................
may be some how when the MDI form call again then it will hit on Timersplash intialise line. and then the error throws.
So, What will be the solution
Arindam Banerjee
Sr. Software Developer
Rance Computer Pvt Ltd.
Kolkata (India)
|
|
|
|
|
Calling Abort is not safe. It generates ThreadAbortException and it is not guaranteed that the thread will stop working. See what MSDN says about this exception
MSDN
When a call is made to the Abort method to destroy a thread, the common language runtime throws a ThreadAbortException. ThreadAbortException is a special exception that can be caught, but it will automatically be raised again at the end of the catch block.
This is the reason why your code is crashing. You should consider some safe methods for aborting your thread. Use a volatile boolean variable and if is set, exit from the thread manually.
|
|
|
|
|
How can I Abort a thread or exit from a tread without Threading.thread.exception
Arindam Banerjee
Sr. Software Developer
Rance Computer Pvt Ltd.
Kolkata (India)
|
|
|
|
|
You can use a flag variable inside the thread code and check it periodically to see if the code should exit.
|
|
|
|
|
Did you see the VS2008 comes with a SplashScreen component?? If you have the application framework enabled in your project, you can add it just like you added a new form. You can even modify the splash screen form however you like.
Just a thought...
|
|
|
|
|
Hi all,
I have one web methode in my web service,that can only get one table from my application and it is without Transaction,
<WebMethod()> _
Public Function OprationONTbl(ByRef ds As Data.DataSet, ByVal TblName As String, ByVal Insert As Boolean, ByVal Update As Boolean, ByVal StrWhere As String, ByVal retValue As Boolean, ByRef StrRetValue As String) As String
Dim cn As New SqlConnection
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim cBuilder As New SqlCommandBuilder(da)
Try
'-*-> cn
Dim cls As New clsGeneral
cn.ConnectionString = cls.GetConnection
cls = Nothing
'-*-> cmd
cmd.CommandText = "Select * From " & TblName
If StrWhere.Trim <> "" Then cmd.CommandText = cmd.CommandText & " WHERE " & StrWhere
cmd.Connection = cn
'-*-> da
da.SelectCommand = cmd
'**************************************'
If Not Insert And Not Update Then
da.Fill(ds, TblName)
End If
'**************************************'
If Insert Then
da.InsertCommand = cBuilder.GetInsertCommand
da.Update(ds.Tables(TblName))
If retValue Then
cmd.CommandText = "Select Max(Id) from " & TblName
cn.Open()
StrRetValue = cmd.ExecuteScalar
cn.Close()
End If
End If
'**************************************'
If Update Then
Dim value() As String = StrWhere.Split("*")
cmd.CommandText = "UpDate " & TblName & " SET " & value(1) & " WHERE " & value(0)
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
End If
Return ""
Catch ex As Exception
Return "OprationONTbl : " & ex.Message
Finally
If cn.State = ConnectionState.Open Then cn.Close()
cn = Nothing
cmd = Nothing
da = Nothing
cBuilder = Nothing
End Try
End Function
Now i want get more table form my application and with transaction, that if i send to webService two tables, with one transaction tow tables be full of data,
now i changed above web method but my result is not true ,i test to many state of this code but it has different Error for Inserting data,
I don't know how i can change this web method for doing my work true.
i write this but it is mistake,
Dim myTblName() As String = TblName.Split("$")
'-*-> cmd
For i As Integer = 0 To myTblName.Length - 1
cmd.CommandText = "Select * From " & myTblName(i)
If StrWhere.Trim <> "" Then cmd.CommandText = cmd.CommandText & " WHERE " & StrWhere
cmd.Connection = cn
'-*-> da
da.SelectCommand = cmd
'**************************************'
If Not Insert And Not Update Then
da.Fill(ds, myTblName(i))
End If
Next
'**************************************'
If Insert Then
Dim trans As SqlTransaction
cn.Open()
trans = cn.BeginTransaction
cmd.Transaction = trans
For i As Integer = 0 To myTblName.Length - 1
da.InsertCommand = cBuilder.GetInsertCommand
da.Update(ds.Tables(myTblName(i)))
If retValue Then
cmd.CommandText = "Select Max(Id) from " & myTblName(i)
StrRetValue = cmd.ExecuteScalar
End If
Next
Try
trans.Commit()
Catch ex As Exception
trans.Rollback()
End Try
End If
'**************************************'
If Update Then
cn.Open()
Dim trans As SqlTransaction
trans = cn.BeginTransaction
cmd.Transaction = trans
For i As Integer = 0 To myTblName.Length - 1
Dim value() As String = StrWhere.Split("*")
cmd.CommandText = "UpDate " & myTblName(i) & " SET " & value(1) & " WHERE " & value(0)
cmd.ExecuteNonQuery()
Next
Try
trans.Commit()
Catch ex As Exception
trans.Rollback()
End Try
End If
Return ""
Catch ex As Exception
Return "OprationONTbl : " & ex.Message
Finally
If cn.State = ConnectionState.Open Then cn.Close()
cn = Nothing
cmd = Nothing
da = Nothing
cBuilder = Nothing
End Try
End Function
i need your help,
Thank You
<div class="ForumSig">Hoda </div>
|
|
|
|
|
Don't use Max(Id) and a transaction to get the id, just call "select scope_identity()" after you have made the insert. That is the normal method to get the id, and it will use less resources on the server.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
How will I remove a textbox during runtime by using linklabel in c# language.
|
|
|
|
|
what do you want to do actually
if you want to remove textbox on click of link label then use following
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked<br />
Me.Controls.Remove(TextBox1)<br />
End Sub
and if you want to off the visiblity of the textbox then do following
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
TextBox1.Visible=False
End Sub
hope this helps
|
|
|
|
|
hitesh.kalra wrote: How will I remove a textbox during runtime by using linklabel in c# language.
And you're asking that in a VB forum?
|
|
|
|
|
when i run my application in debug mode it gives me the following error at startup , i am unable to resolve this issue , please help , thanks in advance .....
An error occurred creating the form. See Exception.InnerException for details. The error is: The type initializer for 'Request_Forms.Main' threw an exception.
hello
|
|
|
|
|
You have a static initialiser (called a shared constructor in VB) that is doing something that isn't working. As the error message sayd "See Exception.InnerException" for details. You haven't provided those details so you might want to have a look see.
|
|
|
|
|
Dear Sir
I have designed 20 textboxes in Form1 and i have set some formulaes for the result.
so i wanted to see the 20 textboxes values and result textboxs values in print preview.
for example
Project Calculation Report No.XXXX Page1
Date:DDMMYYYY
Project:XXXXXXXXXXXXX
input Data
___________________________________________________________
Textbox1 Textbox2 Textbox3 Textbox4
Textbox5 Textbox6 Textbox7 Textbox8
Textbox9 Textbox10 Textbox11 Textbox12
Textbox13 Textbox14 Textbox15 Textbox16
Textbox17 Textbox18 Textbox19 Textbox20
____________________________________________________________
Result
Textbox21 Textbox22 Textbox23 Textbox24
_____________________________________________________________
Kindly Help me
|
|
|
|
|
OK, what are you using to generate this report??
|
|
|
|
|
I dont know,how to do it
can you please advise me ,what i have to use to generate the report
|
|
|
|
|
You might want to try CrystalReports.
|
|
|
|
|
I could really use some help with this. I have tested it and refined it a bit and it doesn't work and I need some help. It is in a BG worker. Here is the complete code. Need to try to get this done ASAP.
Public Class prnProcessing
Dim WshNetwork = CreateObject("WScript.Network")
Public arrInstalled As New ArrayList()
Dim WithEvents ToDoWork As New System.ComponentModel.BackgroundWorker
Public Sub prnProcessing_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If prnSelection.arrToInstall.Count > 0 Then
'added 10-2-08
prnProgress.Style = ProgressBarStyle.Continuous
'prnProgress.Dock = DockStyle.Bottom
prnProgress.Visible = False
prnProgress.Minimum = 1
prnProgress.Maximum = prnSelection.arrToInstall.Count
'end add 10-2-08
ToDoWork.WorkerReportsProgress = True
ToDoWork.WorkerSupportsCancellation = True
ToDoWork.RunWorkerAsync(prnSelection.arrToInstall)
Me.CenterToScreen()
Else
MsgBox("There are no printers to install. Please choose the printers you wish to install.")
prnSelection.Show()
Me.Close()
End If
End Sub
Public Sub ToDoWork_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles ToDoWork.DoWork
Dim worker As System.ComponentModel.BackgroundWorker = CType(sender, System.ComponentModel.BackgroundWorker)
If e.Argument IsNot Nothing AndAlso TypeOf (e.Argument) Is ArrayList Then
Dim arrToInstall As ArrayList = e.Argument
If arrToInstall.Count > 0 Then
Dim i As Integer = 1
For Each printer As String In arrToInstall
CallByName(Me, printer, CallType.Method)
worker.ReportProgress(i)
i += 1
System.Threading.Thread.Sleep(200)
Next
End If
End If
End Sub
Public Sub ToDoWork_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles ToDoWork.ProgressChanged
prnProgress.Visible = True
prnProgress.Value = e.ProgressPercentage
End Sub
Public Sub PrinterProgress(ByVal i As Integer, ByVal worker As System.ComponentModel.BackgroundWorker, ByVal e As System.ComponentModel.DoWorkEventArgs)
worker.ReportProgress(i)
End Sub
Public Sub ToDoWork_EndProgress() Handles ToDoWork.RunWorkerCompleted
ToDoWork.Dispose()
prnWrapup.Show()
Me.Close()
End Sub
Public Sub CSE211CLQ()
MsgBox("Does it start??", vbOK)
'arrInstalled.Add("CSE-211-CLQ")
WshNetwork.AddWindowsPrinterConnection("LPR", "\\at-cetus.ad.ufl.edu\CSE-211-CLQ", "True")
MsgBox("Did it install??", vbOK)
Shell("net stop spooler")
Shell("net start spooler")
Shell("rundll32 printui.dll, PrintUIEntry /if /b ""test_1/"" /f ""C:\7760.inf\"" /q /r ""at-cetus.ad.ufl.edu:CSE-211-CLQ/"" /m ""Xerox Phaser 7760GX PS"" /z /u")
MsgBox("Did it install??", vbOK)
End Sub
End Class
I have added two msg boxes before and after and when it gets to the WshNetwork line it just conks out and quits the bg workers and goes to the next form without showing the next msgbox or doing anyother thing. How do I get this to work.
|
|
|
|
|
Trey5498 wrote: WshNetwork.AddWindowsPrinterConnection("LPR", "\\at-cetus.ad.ufl.edu\CSE-211-CLQ", "True")
I don't know if it'll work on a background thread, but that's what I'm looking at.
The arguments you're passing to AddWindowsPrinterConnection are wrong. It's the printer path that goes first (you have it second), then the driver name to use (which you don't specify). On NT Kernel Windows, the third parameter ("True" isn't exactly a valid port name!) is ignored.
|
|
|
|
|
I am trying to get it to be used on the LPR port. How do I get that to work assuming that the fixed line would be:
WshNetwork.AddWindowsPrinterConnection("at-cetus.ad.ufl.edu\CSE-211-CLQ", "Xerox Phaser 7760GX PS", CSE-211-CLQ")
given the following
Port: LPR
Server providing LPD: at-cetus.ad.ufl.edu
Queue Name: CSE-211-CLQ
|
|
|
|
|
You can try this. There's no guarantee that this will work for you.
WshNetwork.AddWindowsPrinterConnection("\\at-cetus.ad.ufl.edu\CSE-211-CLQ", "Xerox Phaser 7760GX PS", "LPR")
|
|
|
|
|
It installed the printer, however it did not create or even use the LPR port. Please how do I direct the driver to a server side .inf file?
and it does seem to work in the BG worker
|
|
|
|
|
Then you're going to have to use WMI to create the connection. It appears that the documentation is correct and the port parameter is ignored on NT/2000 kernel systems.
I don't know the exact process to go through, but you can do the research on it by reading up on the WMI class "Win32_Printer".
|
|
|
|
|
I have to register a .dll, I was using the following code
Imports System.ComponentModel
Imports System.Configuration.Install
Public Class Installer1 ()
Public Sub New ()
MyBase.New ()
InitializeComponent ()
End Sub
Public Overrides Sub Commit(ByVal savedstate As System.Collections.IDictionary)
MyBase.Commit (savedstate)
Dim RegAddin As New Process
RegAddin.StartInfo.FileName=My.Application.Info.DirectoryPath + "\FeatureRName.Bat"
RegAddin.Start ()
This shows the command window with running but the action was not done
the bat file contains
c:\Windows\Microsoft.Net\Framework\v2.0.50727\regasm /codebase FeatureRname.dll
if I run the same bat file manually it works good
Is there any other method to avoid using the bat file and using the code directly in the Installat class
Saseendran Kombath
|
|
|
|
|
You're only running a single command, so why are you using a batch file and not running the command line that it's holding directly using the Process class?
|
|
|
|
|
I have tried to use like below but it is not working
process.start("c:\windows\microsoft.net\framework\v2.0.50727\regasm.exe /codebase " & chr(34) & my.application.info.directorypath & "RenameFeature.dll" & chr(34)
this gives an error
Please help on this
Saseendran Kombath
|
|
|
|