PDA

View Full Version : سیاه شدن پنجره برنامه هنگام واکشی اطلاعات از بانک اطلاعاتی



mostafa_tak2000
چهارشنبه 30 مرداد 1398, 02:59 صبح
باسلام خدمت دوستای عزیز
من مدتی هست که به مشکلی برخورد کردم که خیلی سعی کردم حلش کنم ولی نشد .
من یه نرم افزار دانشجویی داروخانه نوشتم . وقتی اطلاعاتی را از دیتابیس واکشی میکنیم وقتی این مدت بیشتر از حدود 3 الی 5 ثانیه طول میکشه صفحات پشت پنجره فعال نرم افزار سیاه میشن و وقتی واکشی تموم شد دوباره صفحه نرم افزارطبیعی میشه.
یه نکته اینکه در محیط ویژوال استودیو این اتفاق نمیفته ولی وقتی فایل exe نرم افزار را اجرا میکنم این مشکل پیش میاد .
ممنون میشم راهنماییم کنید که مشکل از کجاست ؟؟

hamidrezax1
جمعه 01 شهریور 1398, 17:59 عصر
دوست عزیز نحوه واکشی اطلاعات شما از دیتابیس و همچنن عدم استفاده از ابزار صحیح در واکشی باعث این مشکل میشه.در صورت امکان کدتون قرار بدین تا دوستان راهنمایتون کنن

mostafa_tak2000
شنبه 02 شهریور 1398, 18:42 عصر
باسلام .
من از کامپونت MRG.Controls.UI استفاده میکنم . متوجه شدم که تو هر صفحه از این کد استفاده میکنم اینطوری مشه . راستش من درواقع بااستغاده از این ابراز یک فرم لودینگ ساختم و تو فرمهام فراخوانی میکنمش کد تابعش زیر براتون مینویسم



mports System.Threading


Namespace Samed
Partial Public Class PleaseWait
Inherits Form


Private Shared _LoadingScreenThread As Thread
Private Shared _ls As PleaseWait
Private Shared _shown As Boolean = False
Private Shared _parent As Form


Public Sub New()
InitializeComponent()
End Sub


Public Shared Sub ShowLoadingScreen(ByVal parent As Form)
_parent = parent
If _LoadingScreenThread Is Nothing Then
_LoadingScreenThread = New Thread(New ThreadStart(AddressOf DoShowLoadingScreen))
_LoadingScreenThread.SetApartmentState(ApartmentSt ate.STA)
_LoadingScreenThread.IsBackground = True
_LoadingScreenThread.Start()
End If
End Sub


Public Shared Sub CloseLoadingScreen()
System.Threading.Thread.Sleep(250)
If _ls IsNot Nothing AndAlso _ls.InvokeRequired Then
_ls.Invoke(New MethodInvoker(AddressOf CloseLoadingScreen))
Else
If _shown Then
_shown = False
Application.ExitThread()
End If
If _LoadingScreenThread IsNot Nothing Then
_LoadingScreenThread.Interrupt()
End If


Try
_ls.Close()
_ls.Dispose()


Catch


End Try


_LoadingScreenThread = Nothing
End If
End Sub


Private Shared Sub DoShowLoadingScreen()
_ls = New PleaseWait()
_ls.LoadCircle.Active = True
_ls.ShowDialog()
End Sub


Private Sub PleaseWait_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Me.TopMost = True
Me.Activate()
End Sub


Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(Get Type(PleaseWait))
Me.LoadCircle = New MRG.Controls.UI.LoadingCircle()
Me.PictureBox1 = New System.Windows.Forms.PictureBox()
Me.Label1 = New System.Windows.Forms.Label()
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginIni t()
Me.SuspendLayout()
'
'LoadCircle
'
Me.TopMost = True
Me.LoadCircle.Active = False
Me.LoadCircle.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch
Me.LoadCircle.Color = System.Drawing.Color.DarkGray
Me.LoadCircle.InnerCircleRadius = 5
Me.LoadCircle.Location = New System.Drawing.Point(233, 12)
Me.LoadCircle.Name = "LoadCircle"
Me.LoadCircle.NumberSpoke = 12
Me.LoadCircle.OuterCircleRadius = 11
Me.LoadCircle.RotationSpeed = 100
Me.LoadCircle.Size = New System.Drawing.Size(39, 40)
Me.LoadCircle.SpokeThickness = 2
Me.LoadCircle.StylePreset = MRG.Controls.UI.LoadingCircle.StylePresets.MacOSX
Me.LoadCircle.TabIndex = 0
Me.LoadCircle.Text = "LoadingCircle1"
Me.LoadCircle.Visible = False
'
'PictureBox1
'
Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(-6, -4)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(297, 156)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchIma ge
Me.PictureBox1.TabIndex = 1
Me.PictureBox1.TabStop = False
'
'Label1
'
Me.Label1.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(128, Byte), Integer), CType(CType(0, Byte), Integer))
Me.Label1.Font = New System.Drawing.Font("B Yekan", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(178, Byte))
Me.Label1.ForeColor = System.Drawing.Color.White
Me.Label1.Location = New System.Drawing.Point(-9, 115)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(297, 27)
Me.Label1.TabIndex = 2
Me.Label1.Text = "لطفاً کمی صبر کنید"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'PleaseWait
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(284, 142)
Me.ControlBox = False
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.PictureBox1)
Me.Controls.Add(Me.LoadCircle)
Me.DoubleBuffered = True
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWind ow
Me.Name = "PleaseWait"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScree n
Me.TopMost = True
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit( )
Me.ResumeLayout(False)


End Sub


Friend WithEvents LoadCircle As MRG.Controls.UI.LoadingCircle
Friend WithEvents PictureBox1 As PictureBox
Friend WithEvents Label1 As Label
End Class
End Namespace